Consul container immediately shuts down
$ docker run -d --name=consul --net=host gliderlabs/consul-server -bootstrap
This command succeeds.
$ docker start consul
This command succeeds.
Except.. when you look at the following:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3b90dca86b21 gliderlabs/registrator:latest "/bin/registrator co 54 minutes ago Exited (1) 41 minutes ago registrator
7b6248dcd560 gliderlabs/consul-server:latest "/bin/consul agent - 56 minutes ago Exited (1) 2 minutes ago consul
This is what I get from the docker logs:
$ docker logs consul
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
==> WARNING: Bootstrap mode enabled! Do not enable unless necessary
==> Starting Consul agent...
==> Error starting agent: Failed to get advertise address: Multiple private IPs found. Please configure one.
Registrator also shuts down immeditely since it can't forma connection to the consul container.
I think this is related to https://github.com/hashicorp/consul/issues/725.
What I did was install Consul directly on the Ubuntu 14.04 box, and faced the same error.
Referred to the above mentioned issue on consul, these two commands work (although just running the server cannot elect a leader :).
$ consul agent -server -bind=:: -advertise=2001:db8::1 -data-dir=/tmp/what
$ consul agent -dev -bind=:: -advertise=2001:db8::1
I am new to docker/consul but I am pretty sure https://github.com/gliderlabs/docker-consul/blob/master/0.6/consul-server/Dockerfile#L3 is not something we want to muck with to add -bind etc to. Might be wrong though.
Update: Sidenote, I have just gone through your personal and organization github accounts. Thanks for all the contributions to the community!
Have you tried running consul with the private IP of the VM?
$ machine ip
192.168.99.100
$ docker run --net=host --name=consul gliderlabs/consul-server -advertise=192.168.99.100
After adding the -advertise option, I am getting "No cluster leader" error.
2016/03/31 05:29:32 [ERR] agent: failed to sync remote state: No cluster leader
@mattaitchison This worked for me.
@shantanuo This should be, as there is nothing to do yet -- as far as I understand.
This is what it looks like following http://gliderlabs.com/registrator/latest/user/quickstart/
ubuntu@ip-172-31-30-16:~/_registrator$ docker run -d \
> --name=registrator \
> --net=host \
> --volume=/var/run/docker.sock:/tmp/docker.sock \
> gliderlabs/registrator:latest \
> consul://localhost:8500
bca4e5ea2f3bc346747c4765e1e6ba7269d19b51fdfb1f63ac94ef514b764915
ubuntu@ip-172-31-30-16:~/_registrator$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bca4e5ea2f3b gliderlabs/registrator:latest "/bin/registrator con" 4 seconds ago Up 3 seconds registrator
6713e091e31a gliderlabs/consul-server "/bin/consul agent -s" 2 minutes ago Up 2 minutes consul
ubuntu@ip-172-31-30-16:~/_registrator$
ubuntu@ip-172-31-30-16:~/_registrator$ docker logs registrator
2016/04/11 13:18:22 Starting registrator v6 ...
2016/04/11 13:18:22 consul: current leader 192.168.99.100:8300
2016/04/11 13:18:22 Using consul adapter: consul://localhost:8500
2016/04/11 13:18:22 Listening for Docker events ...
2016/04/11 13:18:22 Syncing services on 2 containers
2016/04/11 13:18:22 ignored: bca4e5ea2f3b no published ports
2016/04/11 13:18:22 ignored: 6713e091e31a no published ports
It is now working as explained in quickstart guide. The only change needed was to add advertise along with bootstrap, something like this...
docker run -d --name=consul --net=host gliderlabs/consul-server -bootstrap -advertise=52.200.204.48
$ docker run -d
--name=registrator
--net=host
--volume=/var/run/docker.sock:/tmp/docker.sock
gliderlabs/registrator:latest
consul://localhost:8500
Update: I can use python docker module to get this info. But in order to access remote host, I need to start docker in insecure mode using... OPTIONS="--host=tcp://0.0.0.0:2375"
I can not use this trick in production for obvious reasons. Launching another container to watch containers is a smart idea. Thanks for this image.