我一直关注these instructions在我的Ubuntu机器上设置一个docker swarm。我想在运行swarm管理器的同一台机器上运行一些swarm节点,但是节点的状态是" Pending"错误"无法连接到docker引擎端点"。
这些是我为设置系统而运行的命令:
docker run -d --name consul -p 8500:8500 progrium/consul -server -bootstrap
docker run --name manager -d -p 4000:4000 swarm manage -H :4000 --advertise 192.168.1.18:4000 consul://192.168.1.18:8500
docker run -d -p 6300:2375 swarm join --advertise=192.168.1.18:6300 consul://192.168.1.18:8500
我注意到的一件事是节点没有绑定到端口:
$ nmap localhost
Starting Nmap 6.40 ( http://nmap.org ) at 2016-03-02 15:06 EST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00054s latency).
Other addresses for localhost (not scanned): 127.0.0.1
Not shown: 996 closed ports
PORT STATE SERVICE
4000/tcp open remoteanything
8500/tcp open fmtp
这是来自docker info的输出:
$ docker -H :4000 info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: swarm/1.1.2
Role: primary
Strategy: spread
Filters: health, port, dependency, affinity, constraint
Nodes: 1
(unknown): 192.168.1.18:6300
└ Status: Pending
└ Containers: 0
└ Reserved CPUs: 0 / 0
└ Reserved Memory: 0 B / 0 B
└ Labels:
└ Error: Cannot connect to the docker engine endpoint
└ UpdatedAt: 2016-03-02T18:44:38Z
Plugins:
Volume:
Network:
Kernel Version: 4.2.0-30-generic
Operating System: linux
Architecture: amd64
CPUs: 0
Total Memory: 0 B
Name: 739dc6a5c721
非常感谢任何帮助!
答案 0 :(得分:3)
在these instructions之后看起来事情正在发挥作用。总而言之,您应该在主机上编辑/etc/default/docker
以包含以下行:
DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"
然后你应该重启docker:
sudo restart docker
我遇到了这个问题,因为安装程序会自动启动docker引擎(至少在Ubuntu上)。这导致指令3.3(sudo docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
)失败,因为它已经在运行。