I have a docker-compose.yml file that I use to run a web application.
version: \'3\'
services:
web:
entrypoint: gunicorn myapp.wsgi:application --bind 0.0
Docker provides a DNS service (search for “automatic DNS resolution between containers”), and Docker Compose provides a default “user-defined” network that uses it. If you look at /etc/resolv.conf
inside your container, it should point at a Docker-private IP addresses which provides hostname resolution for both the general Internet and for other containers.
More specifically in a Docker Compose context, the name of each entry in the services:
block is resolvable as a host name by other containers launched from the same docker-compose.yml
file. You do not need to set container_name:
, hostname:
, links:
, or networks:
; this is all configured automatically for you.