Linked Questions

Popular Questions

Docker DNS with Multiple Projects Using the Same Network

Asked by At

I have the following docker-compose.yml file:

version: '3'
services:
    frontend:
        image: alpine
        command: tail -f /dev/null
        networks:
            - shared
            - default
    backend:
        image: alpine
        command: tail -f /dev/null
        networks:
            - shared
            - default
networks:
    shared:
        external: true

Based on the file from above I create two projects which use the same network (shared) and the same service names (frontend and backend):

docker-compose -p foo up -d
docker-compose -p bar up -d

Does the DNS of docker make sure that docker-compose -p foo exec frontend ping backend only resolves to the backend container in project foo and vice versa for project bar?

Related Questions