docker networking, duplicate host

I have multiple environments running of the same application. the host for some of the containers are identical. for instance:

because of this, the api host was resolving to two different containers everytime i refresh the page.

seems as if when I restarted nginx inside the container that is accessing the duplicated host, things started working, but then started breaking again when I restart nginx in any of the containers. not sure whats going on.

I found out that setting the Host header was causing the issues, but im not sure why.

I looked into networking more and I found this

https://docs.docker.com/network/links/

this is how it works in docker-compose

“we recommend that you use user-defined networks to facilitate communication between two containers instead of using --link

so I created a network called internal-network that connects only containers that define that network. This fixed it.

Leave a Reply

Your email address will not be published.