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 - You can also create a development copy of your Docker Compose file. For example, if you had .devcontainer/docker-compose.devcontainer.yml, you would just change the following line in devcontainer.json:
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

Discussions

devcontainer docker-compose best practice - Stack Overflow
I have an existing Django project using docker compose and I am trying to add devcontainer support. I have it mostly working except there is still one thing that is bothering me. In my docker-compo... 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
Devcontainer
Yeah, use healthchecks. First google result looks pretty close to what you need: https://github.com/peter-evans/docker-compose-healthcheck/blob/master/docker-compose.yml More on reddit.com
🌐 r/docker
7
4
April 20, 2023
[deleted by user]
Extremely annoying to attempt to mandate an IDE More on reddit.com
🌐 r/ExperiencedDevs
78
16
June 10, 2023
🌐
GitHub
github.com › microsoft › vscode-dev-containers › blob › main › container-templates › docker-compose › .devcontainer › docker-compose.yml
vscode-dev-containers/container-templates/docker-compose/.devcontainer/docker-compose.yml at main · microsoft/vscode-dev-containers
# This is where VS Code should expect to find your project's source code and the value of "workspaceFolder" in .devcontainer/devcontainer.json · - ..:/workspace:cached · · # Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker-compose for details.
Author   microsoft
🌐
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 ...
🌐
Development Containers
containers.dev › guide › dockerfile
Using Images, Dockerfiles, and Docker Compose
You can also combine these scenarios and use Dockerfile with Docker Compose. This time we’ll update docker-compose.yml to reference the Dockerfile by replacing image with a similar build section: version: '3.8' services: devcontainer: build: context: .
🌐
Visual Studio Code
code.visualstudio.com › docs › devcontainers › containers
Developing inside a Container
November 3, 2021 - You can also create a devcontainer.json by hand and use any image, Dockerfile, or set of Docker Compose files as a starting point. Here is a simple example that uses one of the pre-built Development Container images:
Find elsewhere
🌐
GitHub
github.com › joeriddles › devcontainer-compose
GitHub - joeriddles/devcontainer-compose: An example devcontainer project using docker compose · GitHub
This repo demonstrates how to setup a VS Code devcontainer using multiple docker-compose files. .env file must be in the same directory as the docker-compose files. See this issue for more info. In this repo, we have duplicated .env from the base directory to also the subdirectory /docker. code is the container that VS Code will attach to. We mount our source code into the container. app is the example Python application.
Author   joeriddles
🌐
Visual Studio Code
code.visualstudio.com › remote › advancedcontainers › connect-multiple-containers
Connect to multiple containers
November 3, 2021 - Next, you can set up ./devcontainer/node-container/devcontainer.json for Node.js development by changing workspaceFolder. { "name": "Node Container", "dockerComposeFile": ["../../docker-compose.yml"], "service": "node-app", "shutdownAction": "none", "workspaceFolder": "/workspace/node-src" }
🌐
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 - A devcontainer is a feature that lets you run docker containers locally for development. This brings a lot of advantages! I listed a few here: ... Doesn’t matter what operating system, version or compatability your local device has. (It’s built for that purpose!) ... FYI: For this part some docker knowledge is required and is not getting teached. Now in this example let’s create a simple and small NodeJS devcontainer
🌐
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 - You can see the docker-compose.yml at the root of the project folder. We use this for deploying our stack in our production or staging server · The backend folder contains code for our FastAPI backend which uses python 2a. It has its own .devcontainer which contain configs for when we want to set up backend as a stand-alone dev/docker container
🌐
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 - 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.
🌐
DEV Community
dev.to › rafalsz › docker-compose-and-devcontainers-for-microservices-development-44b8
Docker Compose and Devcontainers for Microservices Development - DEV Community
April 28, 2025 - All routing to other services will work either using direct connection to other containers (for example http://svc2:3000), or using Traefik (http://host.docker.internal:3000/svc2). You will still have your local-development features, like hot-reload or debugging. Because the devcontainer shares the shared-network with the services run by the main compose.yml, you can connect from your devcontainer (svc1) to other services (svc2) in two main ways:
🌐
Cloudomation
cloudomation.com › home › blog › blog › devfile & devcontainer vs. dockerfile & docker-compose
Devfile & devcontainer vs. Dockerfile & Docker-Compose
May 22, 2025 - 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 file in the repository,
🌐
Atomic Spin
spin.atomicobject.com › docker-development-container
Using Docker as a Dev Environment with VS Code: Part 2
June 16, 2021 - Here’s what the entire docker-compose.dev-container.yml file now looks like: version: "3.8" services: app: build: context: .. dockerfile: .devcontainer/Dockerfile.dev init: true volumes: # Forwards the local Docker socket to the container.
🌐
GitHub
github.com › h4l › dev-container-docker-compose-volume-or-bind
GitHub - h4l/dev-container-docker-compose-volume-or-bind: A template for Docker Compose devcontainers supporting both bind mounts and container volumes · GitHub
An example Dev Container configuration for a Docker Compose project with workspace code accessed from the local filesystem via a bind mount, or with the project code in a Docker container volume.
Starred by 26 users
Forked by 4 users
Languages   Shell 99.4% | Dockerfile 0.6%
🌐
BrickCrafted
jacksontong.github.io › 2024 › 12 › 31 › setting-up-a-vscode-devcontainer-using-docker-compose.html
Setting Up a VSCode Devcontainer Using Docker Compose | BrickCrafted
December 31, 2024 - Next, define your services in a docker-compose.yaml file. Here is an example configuration: services: app: image: mcr.microsoft.com/vscode/devcontainers/go:1.23-bookworm ports: - "${APP_PORT:-8080}:8080" volumes: - .:/workspace:cached command: sleep infinity db: image: postgres:17 volumes: - db-data:/var/lib/postgresql/data environment: POSTGRES_USER: ${DB_USER} POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_DB: ${DB_NAME} pgadmin: image: dpage/pgadmin4 ports: - "${PGADMIN_PORT:-5050}:80" environment: PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL} PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD} volumes: db-data:
🌐
Development Containers
containers.dev › implementors › json_reference
Dev Container metadata reference
Instead, container orchestrator ... 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 ...
🌐
Medium
medium.com › agoda-engineering › container-based-development-how-to-setup-development-in-docker-with-dev-container-8b3e9d1e065e
Container-based Development: How to Setup Development in Docker with Dev Container | by Agoda Engineering | Agoda Engineering & Design | Medium
September 12, 2023 - // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/dotnet { "name": "C# (.NET)", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/dotnet:0-6.0" // Features to add to the dev container.
🌐
GitHub
github.com › devcontainers › spec › issues › 331
Clarity on how docker compose based devcontainers are built · Issue #331 · devcontainers/spec
November 2, 2023 - 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...
Author   amitds1997