Docker Community Forums

Share and learn in the Docker community.

Docker Swarm can't resolve names from other machine


(Chssch2) #1

I’m running Docker 17.09.0-ce on two machines with Ubuntu 16.04.

I have one as swarm manager and one as worker. The connection works and the stack deployment as well. But I can’t access the container on the manager machine from the worker container by hostname/containername etc.

This is my docker-compose.yml

version: "3.2"
services:
    node:
        image: ubuntu
        deploy:
            placement:
                constraints: [node.role == manager]
        networks:
            - nodes
        command: sleep infinity

    node-woker:
        image: ubuntu
        networks:
            - nodes
        command: sleep infinity
        deploy:
            placement:
                constraints: [node.role == worker]
networks:
    nodes:
        external: true

I run:

docker stack deploy --compose-file docker-compose.yml test

and it deploys to both server:

docker stack ps test
ID                  NAME                IMAGE               NODE                            DESIRED STATE       CURRENT STATE            ERROR               PORTS
7jxtn5wzadls        test_node.1         ubuntu:latest       db1                             Running             Running 13 minutes ago                       
azqokudgtoxs        test_node-woker.1   ubuntu:latest       Ubuntu-1604-xenial-64-minimal   Running             Running 13 minutes ago        

But if I exec into the worker-container and try to do a nslookup on the name of the first container (tried the service name “test_node.1”, “node”, “test_node”, “test_node.1.7jxtn5wzadls2ucnfsoq1fkee” etc. it can’t resolve anything.

If I run both containers in the same machine it works.

How can I reach the container on the other machine over the overlay network?

Thanks,

Christoph


(Archimedes Trajano) #2

Having the exact same issue it Docker CE 17.12 on CentOS. Works if the swarm is single member only. Have you found a way to resolve this?