Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker consul-server not exposing port #138

Open
perrohunter opened this issue Jun 1, 2016 · 3 comments
Open

docker consul-server not exposing port #138

perrohunter opened this issue Jun 1, 2016 · 3 comments

Comments

@perrohunter
Copy link

Following the quickstart guide, after successfully starting a consul, I cannot perform curl calls to it

docker run -d --name=consul -p 8300:8300 -p 8500:8500 --net=host gliderlabs/consul-server -bootstrap -advertise=127.0.0.1

issuing docker ps list the container but no open ports.

I'm using the Docker 1.11 Beta for OS X

@missedone
Copy link

hi @perrohunter
I can see the ports open though I'm encountering some other issue.
I'm using Docker for OS X Beta: Version 1.11.2-beta15 (build: 9168)

nick@localhost ~ $ docker version
Client:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   b9f10c9
 Built:        Wed Jun  1 21:20:08 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.11.2
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   56888bf
 Built:        Mon Jun  6 23:57:32 2016
 OS/Arch:      linux/amd64
nick@localhost ~ $ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                                                                                                          NAMES
49c261c17c53        gliderlabs/consul-server   "/bin/consul agent -s"   2 minutes ago       Up 2 minutes        0.0.0.0:8400->8400/tcp, 8300-8302/tcp, 8600/tcp, 8301-8302/udp, 0.0.0.0:8500->8500/tcp, 0.0.0.0:53->8600/udp   consul

but I failed to run registrator docker:

nick@localhost ~ $ docker logs registrator
2016/06/17 12:51:05 Starting registrator v7 ...
2016/06/17 12:51:05 Using consul adapter: consul://127.0.0.1:8500
2016/06/17 12:51:05 Connecting to backend (0/0)
2016/06/17 12:51:05 Get http://127.0.0.1:8500/v1/status/leader: dial tcp 127.0.0.1:8500: connection refused

if tried to list consul nodes with curl:

nick@localhost ~ $ curl -L http://127.0.0.1:8500/v1/catalog/node
Missing node name%

but the same commands all works fine within my Ubuntu 14.04 VirtualBox VM.

@missedone
Copy link

looks like if I add --net=host, I got the same issue as @perrohunter :

vagrant@vagrant:~$ docker run -d --name=consul --net=host -p 8400:8400 -p 8500:8500 gliderlabs/consul-server -node node1 -bootstrap -advertise 192.168.59.104 -client 0.0.0.0
93685796d094f172ed0f0d96fca1f45d60827902bfe62d0859556c970e682402
vagrant@vagrant:~$ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS               NAMES
93685796d094        gliderlabs/consul-server   "/bin/consul agent -s"   6 seconds ago       Up 5 seconds                            consul

without --net-host:

vagrant@vagrant:~$ docker run -d --name=consul -p 8400:8400 -p 8500:8500 gliderlabs/consul-server -node node1 -bootstrap -advertise 192.168.59.104 -client 0.0.0.0
9a179fd4068e155ae9be34a17a36ab7ab330abba83fafd59e5c94e1e2c49ed04
vagrant@vagrant:~$ docker ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                                                                                              NAMES
9a179fd4068e        gliderlabs/consul-server   "/bin/consul agent -s"   2 seconds ago       Up 2 seconds        0.0.0.0:8400->8400/tcp, 8300-8302/tcp, 8301-8302/udp, 8600/tcp, 8600/udp, 0.0.0.0:8500->8500/tcp   consul

@onetwopunch
Copy link

onetwopunch commented Dec 29, 2016

@missedone If you're trying to list the nodes, the reason you're getting the Missing node name error is the /node endpoint is a show action. To actually list, try the plural:

curl -L http://127.0.0.1:8500/v1/catalog/nodes

You should get something like:

[{"Node":"consul1","Address":"172.17.0.2"},{"Node":"consul2","Address":"172.17.0.3"},{"Node":"consul3","Address":"172.17.0.4"}]```

Also I've written a little helper bash script for myself to make this work and give access to the web UI as well. BTW This is with docker version 1.12.5 on macOS.

# consul.sh

# Spins up three consul containers in a cluster and outputs the IP Address of the first node

function consul_start() {
	docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp \
		--name consul1 -h consul1 progrium/consul -server \
		-bootstrap-expect 3 -ui-dir /ui
	JOIN_IP=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' consul1)
	docker run -d --name consul2 -h consul2 progrium/consul -server -join $JOIN_IP
	docker run -d --name consul3 -h consul3 progrium/consul -server -join $JOIN_IP

	echo "Consul IP: $JOIN_IP"
        echo "Visit: http://127.0.0.1:8500/ui"
}

function consul_stop() {
	docker stop consul1 consul2 consul3
}

function consul_kill() {
	consul_stop
	docker rm consul1 consul2 consul3
}

case "$1" in
	start)
		consul_start
		;;
	stop)
		consul_stop
		;;
	kill)
		consul_kill
		;;
	*)
	 	echo "USAGE: consul.sh start|stop|kill"
		;;

esac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants