I'm using Docker Compose to create two containers. One runs an Nginx web server which serves the mydomain.com
website, and the second needs to send HTTP requests to the first one (using the mydomain.com
domain name).
I don't want to have to check the Nginx container's ip each time I run it and then use docker run --add-host
on the second container. My goal is to run docker-compose up
and that everything be ready.
I know it's not possible, but what I'm looking for is something in the line of:
# docker-compose.yml
nginx_container:
...
second_container:
extra_hosts:
# This is invalid. extra_hosts only accepts ips.
- "mydomain.com:nginx_container"