vscode can only use one service as "the workspace" where the IDE runs. Just like when working locally you are on the IDE and the other services run in other containers.

None of your current services seem "good" for being the IDE workspace, so you would have to add that one. That would be "just like" your host machine, but in the container.

You can use multiple compose files so you can avoid changing your current docker-compose.yml while being able to add your new service.

So, part I:

  1. Create a second docker-compose.yml file (maybe: docker-compose.workspace.yml)
  2. Add one single service to that file, maybe call it "workspace". vscode Remote part will run there. What image? You may use one vscode's precooked ones.
  3. On .devcontainer.json point to both files and define the workspace service:
...
  "dockerComposeFile": [
    "docker-compose.yaml",
    "docker-compose.workspace.yaml"
  ],
  "service": "workspace",
...

Ok. So that gives you the workspace container and everything else on the side. That gets us to the other part of the question:

Is it possible to interact with Docker engine on the host from inside the container? So I can simply have a dev.sh script that can simply up the rabbitmq and influxdb dependencies and then launch whatever microservice I want to run?

First, if you want the docker & docker-compose commands you have to install the packages. Some images have them builtin, others not. You may use your own image, etc.

But that is not enough. You workspace container is ignorant of the host's docker. But it is easy enough to fix. Just add a volume mount:

/var/run/docker.sock:/var/run/docker.sock

On the workspace service. That way vscode will "see" your host's docker and operate with it.

Beware that it is still the host's docker, so you may get into trouble with paths, etc depending on what you do.

Answer from marc.fargas on Stack Overflow
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › create-dev-container
Create a Dev Container
November 3, 2021 - Create a devcontainer.json, which describes how VS Code should start the container and what to do after it connects. Make and persist changes to the dev container, such as installation of new software, through use of a Dockerfile.
🌐
Development Containers
containers.dev › implementors › json_reference
Dev Container metadata reference
Instead, container orchestrator formats can be referenced when needed to manage multiple containers and their lifecycles. Today, devcontainer.json includes scenario specific properties for working without a container orchestrator (by directly referencing an image or Dockerfile) and for using Docker Compose as a simple multi-container orchestrator.
Discussions

How to run docker-compose inside VS Code devcontainer - Stack Overflow
You can use multiple compose files ... current docker-compose.yml while being able to add your new service. ... Add one single service to that file, maybe call it "workspace". vscode Remote part will run there. What image? You may use one vscode's precooked ones. On .devcontainer.json point to both ... More on stackoverflow.com
🌐 stackoverflow.com
devcontainer docker-compose best practice - Stack Overflow
In my docker-compose.yml file, I have a service defined called web. I want to expand the docker image created for the web service to add more dev features. I have created the .devcontainer directory with a devcontainer.json file. I also have a docker-compose.yml file in .devcontainer which ... More on stackoverflow.com
🌐 stackoverflow.com
visual studio code - How to correctly specify multiple docker-compose.yml files in devcontainer.json - Stack Overflow
If I specify only docker-compose.yml in the devcontainer.json file, the container will start correctly, but if I do more than one as described above, an error will occur. More on stackoverflow.com
🌐 stackoverflow.com
Clarity on how docker compose based devcontainers are built
The spec does not provide clarity on how to specify the build context for a Docker compose build. Considering the following project structure | .devcontainer | devcontainer.json | docker-compose.ym... More on github.com
🌐 github.com
5
November 2, 2023
🌐
GitHub
github.com › microsoft › vscode-dev-containers › blob › main › container-templates › docker-compose › .devcontainer › devcontainer.json
vscode-dev-containers/container-templates/docker-compose/.devcontainer/devcontainer.json at main · microsoft/vscode-dev-containers
// connected. Corresponds to a volume mount in .devcontainer/docker-compose.yml · "workspaceFolder": "/workspace", · // Set *default* container specific settings.json values on container create. "settings": {}, · // Add the IDs of extensions you want installed when the container is created.
Author   microsoft
Top answer
1 of 3
26

vscode can only use one service as "the workspace" where the IDE runs. Just like when working locally you are on the IDE and the other services run in other containers.

None of your current services seem "good" for being the IDE workspace, so you would have to add that one. That would be "just like" your host machine, but in the container.

You can use multiple compose files so you can avoid changing your current docker-compose.yml while being able to add your new service.

So, part I:

  1. Create a second docker-compose.yml file (maybe: docker-compose.workspace.yml)
  2. Add one single service to that file, maybe call it "workspace". vscode Remote part will run there. What image? You may use one vscode's precooked ones.
  3. On .devcontainer.json point to both files and define the workspace service:
...
  "dockerComposeFile": [
    "docker-compose.yaml",
    "docker-compose.workspace.yaml"
  ],
  "service": "workspace",
...

Ok. So that gives you the workspace container and everything else on the side. That gets us to the other part of the question:

Is it possible to interact with Docker engine on the host from inside the container? So I can simply have a dev.sh script that can simply up the rabbitmq and influxdb dependencies and then launch whatever microservice I want to run?

First, if you want the docker & docker-compose commands you have to install the packages. Some images have them builtin, others not. You may use your own image, etc.

But that is not enough. You workspace container is ignorant of the host's docker. But it is easy enough to fix. Just add a volume mount:

/var/run/docker.sock:/var/run/docker.sock

On the workspace service. That way vscode will "see" your host's docker and operate with it.

Beware that it is still the host's docker, so you may get into trouble with paths, etc depending on what you do.

2 of 3
9

You would need to add Docker as a feature to your devcontainer.json:

"features": { "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} }

This will allow access to the docker socket on the host.

Working example: devcontainer.json

🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - The command lets you pick a pre-defined container configuration from a list based on your folder's contents, reuse an existing Dockerfile, or reuse an existing Docker Compose file.
🌐
Development Containers
containers.dev › guide › dockerfile
Using Images, Dockerfiles, and Docker Compose
Let’s create a docker-compose.yml file next to your devcontainer.json that references the same image and includes a PostgreSQL database:
🌐
Top Tech Tips
toptechtips.github.io › 2023-05-17-docker-compose-multiple-dev-containers
How to use VS Code Dev Containers with your docker compose deployment for efficient development and deployment
May 17, 2023 - Next, update ./backend/.devcontainer/devcontainer.json to include our override docker compose file - docker-compose.dev.yml
Find elsewhere
🌐
Atomic Spin
spin.atomicobject.com › 2021 › 06 › 16 › docker-development-container
Using Docker as a Dev Environment with VS Code: Part 2
July 16, 2021 - Annoyingly, Docker won’t ... docker-compose. The external designation basically tells the Docker CLI that it doesn’t need to worry about these things. This means you need to create them independently before your containers start up. To do this, I use a bash script to create my volume and network if they don’t already exist. Then, I tell VS Code to run that script via the devcontainer.json ...
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › connect-multiple-containers
Connect to multiple containers
November 3, 2021 - You can then set up ./devcontainer/python-container/devcontainer.json for Python development as follows: { "name": "Python Container", "dockerComposeFile": ["../../docker-compose.yml"], "service": "python-api", "shutdownAction": "none", "workspaceFolder": "/workspace/python-src" }
🌐
Stack Overflow
stackoverflow.com › questions › 61710650 › how-to-correctly-specify-multiple-docker-compose-yml-files-in-devcontainer-json
visual studio code - How to correctly specify multiple docker-compose.yml files in devcontainer.json - Stack Overflow
An error occurred when starting a container with multiple docker-compose files using the VSCode's Remove-Containers feature like Open Folder in Container. Multiple files are specified as follows. # .devcontainer/devcontainer.json "dockerComposeFile": [ "../docker-compose.yml", "docker-compose.devcontainer.yml" ]
🌐
Flaviodelgrosso
flaviodelgrosso.com › blog › vscode-devcontainers
Mastering VS Code Dev Containers with Docker
February 4, 2024 - Create docker-compose.yaml: Craft a docker-compose.yaml file to define services. For instance, pairing the dev container with a PostgreSQL database: ... version: '3' services: dev-container: image: your-custom-image volumes: - ./workspace:/workspace networks: - db-network command: sleep infinity db: image: postgres networks: - db-network environment: POSTGRES_PASSWORD: yourpassword networks: db-network: Update devcontainer.json: Modify devcontainer.json to reference the Docker Compose file:
🌐
Development Containers
containers.dev › implementors › json_schema
devcontainer.json schema
} }, "required": [ "dockerComposeFile", "service", "workspaceFolder" ] } }, "oneOf": [ { "allOf": [ { "oneOf": [ { "allOf": [ { "oneOf": [ { "$ref": "#/definitions/dockerfileContainer" }, { "$ref": "#/definitions/imageContainer" } ] }, { "$ref": "#/definitions/nonComposeBase" } ] }, { "$ref": "#/definitions/composeContainer" } ] }, { "$ref": "#/definitions/devContainerCommon" } ] }, { "type": "object", "$ref": "#/definitions/devContainerCommon", "additionalProperties": false } ] } { "allOf": [ { "$ref": "./devContainer.base.schema.json" }, { "$ref": "https://raw.githubusercontent.com/microsoft/vscode/main/extensions/configuration-editing/schemas/devContainer.codespaces.schema.json" }, { "$ref": "https://raw.githubusercontent.com/microsoft/vscode/main/extensions/configuration-editing/schemas/devContainer.vscode.schema.json" } ] }
🌐
Some Natalie
some-natalie.dev › blog › multiservice-devcontainers
Securing Devcontainers (part 2) - multi-service applications with Docker Compose | Some Natalie's corner of the internet
March 16, 2025 - Here are the relevant JSON keys and why they’re set: Pinning dependencies happens in requirements.txt (for Python) or in the docker-compose.yml file or Dockerfile, same as any other part of an application. The big change from going from one to many services is adding Docker Compose to define how the containers interact and changing our devcontainer.json file to connect to the one with a shell and all the pre-requisites installed.
🌐
Medium
medium.com › @jannismilz › create-a-devcontainer-9191a2d5ff7b
Create a Devcontainer. A devcontainer is a feature that lets… | by Jannis Milz | Medium
March 5, 2024 - devcontainer.json · { "name": "YourProjectName", "build": { "dockerfile": "Dockerfile" }, "settings": { "terminal.integrated.profiles.linux": { "zsh": { "path"…
🌐
GitHub
github.com › devcontainers › spec › issues › 331
Clarity on how docker compose based devcontainers are built · Issue #331 · devcontainers/spec
November 2, 2023 - In docker-compose.yml file (to indicate that it is one directory above from devcontainer.json file where it is used)
Author   amitds1997
🌐
Stack Overflow
stackoverflow.com › questions › 79589884 › how-to-pass-variables-accessible-from-vscode-devcontainer-json-to-docker-compose
visual studio code - How to pass variables accessible from VsCode devcontainer.json to docker-compose.yml - Stack Overflow
It's not great, but you can create an .env file during initializeCommand that will be used by docker-compose.yml. In .devcontainer.json: { "dockerComposeFile": "docker-compose.yml", "service": "my-devcontainer", "initializeCommand": "echo THING_I_WANT_TO_PASS=${localWorkspaceFolderBasename} > .devcontainer/.env" } Share ·
🌐
OneUptime
oneuptime.com › home › blog › how to create dev containers for development environments
How to Create Dev Containers for Development Environments
January 27, 2026 - your-project/ .devcontainer/ devcontainer.json # Main configuration file Dockerfile # Optional custom image docker-compose.yml # Optional multi-container setup src/ package.json
🌐
Cloudomation
cloudomation.com › home › blog › blog › devfile & devcontainer vs. dockerfile & docker-compose
Devfile & devcontainer vs. Dockerfile & Docker-Compose
May 22, 2025 - You open the devfile or devcontainer.json in an IDE that supports these standards. The IDE asks you if you want to execute the configuration. If you choose to do so, it will do what is specified in the configuration. For example, it could: Pull images from a registry or create images from dockerfiles /docker-compose ...
🌐
GitHub
github.com › devcontainers › spec › blob › main › docs › specs › devcontainerjson-reference.md
spec/docs/specs/devcontainerjson-reference.md at main · devcontainers/spec
Instead, container orchestrator formats can be referenced when needed to manage multiple containers and their lifecycles. Today, devcontainer.json includes scenario specific properties for working without a container orchestrator (by directly referencing an image or Dockerfile) and for using Docker Compose as a simple multi-container orchestrator.
Author   devcontainers