Help with Docker Compose Error: Conflicting Network Options
Asked by
hplc+elute
I'm having trouble deploying my Docker stack and keep running into the following error: 'Failed to deploy a stack: compose up operation failed: Error response from daemon: conflicting options: port publishing and the container type network mode.' I'm still learning about YAML and Docker Compose, so I'm not entirely sure what's going wrong. Below is the configuration I'm working with. Could someone shed some light on this for me?
Answers
Looks like youโre hitting a classic issue with Docker. The error means youโre trying to use conflicting options. Specifically, your Nginx container is set to use the 'network_mode: service:vpn', but you're also trying to publish ports for it. This won't work because you canโt mix port publishing with certain network modes. You need to decide how you want to expose your service without causing these conflicts.
Reply to this answer
To add to that, OP, there are some flags you can't use if your container's network mode is set to another service, like your Nginx container. Specifically, options related to networking (like `--publish` and `--expose`) won't be supported. Take a look at the official Docker documentation for more details on this!
Reply to this answer
Add your answer
Answers are reviewed before publication.
hplc+elute: Thanks for the pointers! I'll definitely check the documentation.