devcontainers / templates

Repository for Dev Container Templates that are managed by Dev Container spec maintainers. See https://github.com/devcontainers/template-starter to create your own!
https://containers.dev/templates
MIT License
859 stars 226 forks source link

rust-postgres template does not work #260

Closed NickUfer closed 3 weeks ago

NickUfer commented 1 month ago

When I use the template from this commit, I get this error:

Error response from daemon: conflicting options: port publishing and the container type network mode

I omit posting my config as it is the exact same as in this commit. I try to run this locally via JetBrains's RustRover.

When I remove network_mode: service:db from the app service in the docker compose file it at least starts.

samruddhikhandale commented 1 month ago

The error message you're seeing is due to a conflict between the network_mode: service:db option and the port publishing options in your Docker Compose file.

When you set network_mode: service:<name>, it means your service app is using the network stack of the service db. In this mode, it doesn't have its own network space, so you can't publish ports directly from this service. That's why you're seeing a conflict.

If you want your app service to communicate with the db service and also publish ports, you should use the default bridge network mode (which is used when network_mode is not specified). In this mode, all services can communicate with each other and you can publish ports from any service.

samruddhikhandale commented 3 weeks ago

Feel free to reopen the issue if this comment doesn't resolve your problem or if you have any follow-up questions. Thanks!