Visual Studio Code with Containers

Visual Studio Code (VSC) is able to provide an experience that emulates local development while utilizing containers.


  • Install Docker.
    • Once Docker is installed right click on the Docker taskbar icon and choose Settings / Preferences > Shared Drives / File Sharing. You’ll need to add any drives you intend to have projects on to this sharing.
  • I recommend installing the Docker extension for VSC from Microsoft, though this is not required.
  • Install the Remote Development pack from Microsoft which includes all the remote development tools or you can strip it down to only Remote – Containers.

Getting Started

VSC’s Container Config File

  • devcontainer.json tells VSC how to access (or create) a development container.
  • Use Remote-Containers: Add Development Container Configuration Files… command to add the file to a folder.
  • When you edit a devcontainer.json VSC does not reload the container by default, you’ll need to issue a command to do so.
    • Remote-Containers: Rebuild Container.

Attaching to Running Containers

  • If one already has a container one can attach to it.
  • This will not create / use a devcontainer.json but extensions that should be installed can be configured in settings.json.
  • Remote-Containers: Attach to Running Container OR use the Docker extension

Managing Docker Containers

  • One can use the Docker extension
  • Or use the Docker CLI
  • Or use Docker Compose

Managing Extensions

  • Extensions that don’t affect the VS Code UI can be installed directly on the container and don’t need to be installed on the local VSC. This allows one to fully swap toolchains by connecting to a different container.

Forwarding Ports

  • To permanently add a forwarded port use devcontainer.json: edit the appPort property
  • Or Dockerfile, or Docker Compose file: edit the ports mapping in docker-compose.yml
  • To temporarily forward for the session use Remote-Containers: Forward Port from Container...
  • Select the desired port (if there aren’t any listed there aren’t any speaking).

Opening a Terminal

  • Any terminal opened in VSC after opening a folder in a container will start in the remote system.

Debugging in a Container

  • Runs the same as locally once the folder has been opened in a container.

Container Specific Settings

  • Preferences: Open Remote Settings after a folder has been opened in a container.
  • Or by selecting Remote tab in the settings editor.

Sharing Git Credentials with Your Container

  • If you use HTTPS to clone repos and have a credential helper configured in local OS, no setup is needed.
  • If using SSH, see the documentation.