如何在docker-compose中使用dnsdock?

时间:2015-12-04 13:55:32

标签: dns docker-compose

我试图使用dnsdock链接docker-compose环境中的容器。

dnsdock:
    image: tonistiigi/dnsdock
    volumes:
        - /var/run/docker.sock:/run/docker.sock
    ports:
        - 172.17.42.1:53:53/udp

pinger1:
  image: gliderlabs/alpine
  command: ping pinger2.pinger2.docker
  dns: 172.17.42.1
  environment:
   - DNSDOCK_NAME=pinger1
   - DNSDOCK_IMAGE=pinger1

pinger2:
  image: gliderlabs/alpine
  command: ping pinger1.pinger1.docker
  dns: 172.17.42.1
  environment:
   - DNSDOCK_NAME=pinger2
   - DNSDOCK_IMAGE=pinger2

在启动时得到了下一个问题:

ERROR: Cannot start container 7cebbcde6c7ae85faaefd655aeb18a53710588c930888e15bdeb3c7392bda027: failed to create endpoint docker_dnsdock_1 on network bridge: Error starting userland proxy: listen udp 172.17.42.1:53: bind: cannot assign requested address

使用简单命令运行: sudo docker-compose -f dnsdock-test.yml up

也许有人知道配置有什么问题?

1 个答案:

答案 0 :(得分:3)

用172.17.0.1而不是172.17.42.1

替换ip后,对我有用