Search code examples
vscode-remote

Multiple devcontainers in vscode-remote


I have a project that creates multiple Docker images. I would like to setup a devcontainer in vscode-remote for each image so that I may spin up a container for each image.

I only need to spin up and connect to one container/image at a time.

Is it supported to have multiple devcontainer files? Maybe something like .devcontainer/devcontainer1.json and .devcontainer/devcontainer2.json (supposing I only had two images that I wanted to use)?

Each devcontainer would use an image with a different name and also requires different runArgs.


Solution

  • I found the other answers too cumbersome as they only work with F1 -> Dev Containers: Open Folder in Container and discovered that (with VS Code v1.77) if you place your devcontainer.json files in subfolders of .devcontainer it even works with F1 -> Dev Containers: Reopen in Container offering you a selection of all your services rightaway without the need to dig through your folder structure.

    screenshot VS Code devcontainer selection