how does docker-compose map my service names into IP addresses?

后端 未结 1 1576
滥情空心
滥情空心 2021-01-25 09:49

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         


        
相关标签:
1条回答
  • 2021-01-25 10:28

    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.

    0 讨论(0)
提交回复
热议问题