Skip to content

My VSCode Devcontainer for all the things I need for my DevOps role

Notifications You must be signed in to change notification settings

ginolatorilla/vscode-dev-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 

Repository files navigation

My VSCode Development Container

Here I define my development container that I use with the Remote - Containers plugin in VSCode. This is oriented for a DevOps role.

Features

  • 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.

Installation

Windows

  1. Install WSL2.
  2. Install Docker Desktop.
  3. Go to Docker Desktop Settings and check Use the WSL 2 based engine.
  4. Install VSCode, and the extensions Remote - Containers and Remote - WSL.
  5. Connect VSCode to WSL2 using the Remote - WSL extension.
  6. Open a terminal, clone this repo, and reopen it in VSCode.
  7. Open the Command Palette (Ctrl+Shift+P) and select Rebuild Container.

Mac

  1. Install Docker Desktop.
  2. Install VSCode, and the extension Remote - Containers.
  3. Clone this repo and reopen it in VSCode.
  4. Open the Command Palette (Ctrl+Shift+P) and select Rebuild Container.

Linux

  1. Install Docker Desktop or Docker Engine.
  2. Install VSCode, and the extension Remote - Containers.
  3. Clone this repo and reopen it in VSCode.
  4. Open the Command Palette (Ctrl+Shift+P) and select Rebuild Container.

Usage Patterns

Access the host's SSH agent

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

About

My VSCode Devcontainer for all the things I need for my DevOps role

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published