jp.rider63
jp.rider63

Reputation: 584

How do I run a docker swarm node on the same machine as the swarm manager?

I have been following these instructions to set up a docker swarm on my Ubuntu machine. I'd like to run some swarm nodes on the same machine that is running the swarm manager, but the status of the nodes are "Pending" with the error "Cannot connect to the docker engine endpoint".

These are the commands I ran to set up the system:

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

One thing I noticed is that the node isn't bound to a port:

$ 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

Here's the output from 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

Any help would be greatly appreciated!

Upvotes: 7

Views: 5957

Answers (1)

jp.rider63
jp.rider63

Reputation: 584

It looks like things are working now after following these instructions. To summarize, on the host machine you should edit /etc/default/docker to include the following line:

DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"

You should then restart docker:

sudo restart docker

I ran into this issue since the installer automatically starts the docker engine (on Ubuntu at least). This causes instruction 3.3 (sudo docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock) to fail since it's already running.

Upvotes: 4

Related Questions