Building only required docker-compose.yaml services with VS Code Dev Container

241 views Asked by At

I'm using VS Code Dev Container extension to develop and run my app inside a Docker container.

I'm using a docker-compose.yaml to re-use an already defined image with a dependent service.

Inside that docker-compose.yaml file I have yet another service for testing purposes. When VS Code starts it builds all of the services inside my docker-compose.yaml file, not just the two I need to develop my application.

I can see Dev Container extension runs the command Start: Run: docker-compose --project-name proj1 -f c:\dev\proj1\docker-compose.yaml -f c:\dev\proj1\.devcontainer\docker-compose.yml up -d --build

If it would have passed the service defined in devcontainer.json it would have built only it.

Is there a way to instruct VS Code's Dev Container extension to build only the service I need for my development?

1

There are 1 answers

0
Evedel On BEST ANSWER

Adding

"runServices": ["devcontainer-1", "devcontainer-2"],

to .devcontainer/devcontainer.json will make vscode to only build and run listed services.