Here I define my development container that I use with the Remote - Containers plugin in VSCode. This is oriented for a DevOps role.
- Your host's username will be used inside. You can run
sudo
to elevate permissions. - Run
docker
inside. The container's Docker CLI will connect to the host's Docker daemon. - Preserve your home directory (shell history and configuration files) across container rebuilds.
- Hook script if you need custom initialisation of the container.
- Third-party packages are listed in
.devcontainer/install-packages.sh
so that you can use this script in a Linux host (e.g. WSL2). - Integrates with ginolatorilla/dotfiles.
- Install WSL2.
- Install Docker Desktop.
- Go to Docker Desktop Settings and check Use the WSL 2 based engine.
- Install VSCode, and the extensions Remote - Containers and Remote - WSL.
- Connect VSCode to WSL2 using the Remote - WSL extension.
- Open a terminal, clone this repo, and reopen it in VSCode.
- Open the Command Palette (Ctrl+Shift+P) and select Rebuild Container.
- Install Docker Desktop.
- Install VSCode, and the extension Remote - Containers.
- Clone this repo and reopen it in VSCode.
- Open the Command Palette (Ctrl+Shift+P) and select Rebuild Container.
- Install Docker Desktop or Docker Engine.
- Install VSCode, and the extension Remote - Containers.
- Clone this repo and reopen it in VSCode.
- Open the Command Palette (Ctrl+Shift+P) and select Rebuild Container.
Use this Bash script to reconnect to the SSH agent socket that's created by VSCode:
export SSH_AUTH_SOCK=$(find /tmp -name 'vscode-ssh-auth-*')
You may also use this script to attach to the container from outside VSCode:
DEVCONTAINER=$(docker container ls | grep vscode-dev-container | awk '{print $1}')
SSH_AUTH_IN_CONTAINER=$(docker exec $DEVCONTAINER sh -c 'ls -t /tmp/vscode-ssh-auth* 2>/dev/null' | head -1)
docker exec -it -e SSH_AUTH_SOCK=$SSH_AUTH_IN_CONTAINER -u $USER -w /home/$USER $DEVCONTAINER bash