我一直在关注these instructions在我的Ubuntu机器上设置一个docker swarm.我想在运行swarm管理器的同一台机器上运行一些swarm节点,但节点的状态为“Pending”,错误为“无法连接到docker engine endpoint”.
这些是我运行以设置系统的命令:
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信息的输出:
$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
任何帮助将不胜感激!
最佳答案
看起来在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)失败,因为它已经在运行.