网络 – 在多主机环境中,容器无法以群集模式相互连接

我在DigitalOcean上运行了3个节点(1GB,带有私有网络),在部署此堆栈后,容器无法使用主机别名连接到其他容器.

这是我的docker-compose.yml文件:

version: "3"

services:
  mongo:
    image: mongo
    ports:
      - 27017:27017
    networks:
      mynet:
        aliases:
          - mongo
    deploy:
      placement:
        constraints: [node.role == manager]

  redis:
    image: redis
    ports:
      - 6379:6379
    networks:
      mynet:
        aliases:
          - redis
    deploy:
      placement:
        constraints: [node.role == worker]

  app:
    image: node
    ports:
      - 3030:3030
    networks:
      - mynet
    depends_on:
      - redis
      - mongo
    deploy:
      mode: replicated
      replicas: 2
      placement:
        constraints: [node.role == worker]

networks:
  mynet:

问题

root@mongo-container:/# ping mongo # works
root@mongo-container:/# ping redis # doesn't work

root@redis-container:/# ping redis # works
root@redis-container:/# ping mongo # doesn't work

root@app-container:/# ping mongo # doesn't work
root@app-container:/# ping redis # doesn't work

组态

daemon.json

{ "userland-proxy": false }

泊坞版:

Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:50:14 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   092cba3
 Built:        Wed Feb  8 06:50:14 2017
 OS/Arch:      linux/amd64
 Experimental: true

任何想法,如何解决这个问题?

最佳答案 这是Docker Swarm模式下的
bug,它在即将发布的Docker
v17.04.0中得到修复

点赞