vscode-dev-containers icon indicating copy to clipboard operation
vscode-dev-containers copied to clipboard

Consider using/documenting Docker Compose bridge network driver

Open aaronadamsCA opened this issue 3 years ago • 1 comments

The current docs and examples recommend networking Docker Compose services together this way:

Adding another service

You can add other services to your docker-compose.yml file as described in Docker's documentaiton. However, if you want anything running in this service to be available in the container on localhost, or want to forward the service locally, be sure to add this line to the service config:

# Runs the service on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

But by looking at the example from this recent blog post:

https://code.visualstudio.com/blogs/2022/03/08/the-tutorial-problem#_adding-remote-containers

It seems they were able to configure the bridge network driver, and then used it to forward ports between services. Unless I'm missing something (which I might be!) this seems like a better solution.

If that's correct, it would be nice to see updated examples and docs, since it's more obvious (a) how it works and (b) how to scale it by adding a third service. But I also don't know for sure, and certainly don't understand the potential drawbacks.

aaronadamsCA avatar Apr 07 '22 13:04 aaronadamsCA

@burkeholland would love your thoughts here, as the author of https://code.visualstudio.com/blogs/2022/03/08/the-tutorial-problem#_adding-remote-containers.

bamurtaugh avatar Apr 21 '22 17:04 bamurtaugh