Visual Studio Code

Visual Studio Code is an open source IDE from Microsoft that has a robust ecosystem of plugins and supposes most development languages.

Using VSC with Containers

devcontainer.json

  • devcontainer.json tells VSC how to access (or create) a development container, in all of the above referenced instances a devcontainer.json file is either created or an existing one used.
  • 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 one can use the Docker CLI
  • Or one can 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 also 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 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.