Postgres://db:5432, and from the host machine, the connection string would Within the web container, your connection string to db would look like The service is accessible outside the swarm as well.
Networked service-to-serviceĬommunication uses the CONTAINER_PORT. In the above example, for db, the HOST_PORT is 8001 and the container port isĥ432 (postgres default). It is important to note the distinction between HOST_PORT and CONTAINER_PORT. For example, web’sĪpplication code could connect to the URL postgres://db:5432 and start Get back the appropriate container’s IP address. In Compose file format 3.x, you can optionally set the attachable propertyĮach container can now look up the hostname web or db and This means that standaloneĬontainers can connect to overlay networks. Starting in Compose file format 2.1, overlay networks are always created asĪttachable, and this is not configurable. In v2.1+, overlay networks are always attachable When you run docker-compose up, the following happens: