Open chiefy opened 7 years ago
Is there a solution for this?
@chugh-rahul this is probably not the best way, but here's my docker-compose orchestration to get a server running alongside three agents...
version: '2'
services:
consul-server:
image: dockertr.es.ad.adp.com/public/consul:0.7.1
ports:
- "8500:8500"
command: agent -server -ui -bind=172.19.0.2 -client=172.19.0.2 -bootstrap-expect=1
networks:
consul_tmp:
ipv4_address: 172.19.0.2
consul-agent-1:
image: dockertr.es.ad.adp.com/public/consul:0.7.1
restart: always
command: agent -join=172.19.0.2 -client=172.19.0.3
networks:
consul_tmp:
ipv4_address: 172.19.0.3
consul-agent-2:
image: dockertr.es.ad.adp.com/public/consul:0.7.1
restart: always
command: agent -join=172.19.0.2 -client=172.19.0.4
networks:
consul_tmp:
ipv4_address: 172.19.0.4
consul-agent-3:
image: dockertr.es.ad.adp.com/public/consul:0.7.1
restart: always
command: agent -join=172.19.0.2 -client=172.19.0.5
networks:
consul_tmp:
ipv4_address: 172.19.0.5
networks:
consul_tmp:
driver: bridge
Example with docker image v0.6.4 works fine
Not working in docker-machine (on macOS) either:
$ docker-machine -v && docker -v
docker-machine version 0.8.0, build b85aac1
Docker version 1.12.0, build 8eab29e
This does not work for me either. On version: Docker version 17.05.0-ce, build 89658be When I run:
docker run -d --name=dev-consul consul
docker run --name agent1 -d consul agent -dev -join=172.17.0.2
docker logs agent1
I get output
==> Starting Consul agent...
==> Joining cluster...
==> 1 error(s) occurred:
* Failed to join 172.17.0.2: dial tcp 172.17.0.2:8301: getsockopt: connection refused
I duplicated the issue on Mac. Will try the workaround.
I'm having this issue on macOS too, with build 0.8.5.
docker version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:31:53 2017
OS/Arch: darwin/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:51:55 2017
OS/Arch: linux/amd64
Experimental: true
The docker compose file solution works. Out of interest, what is the -bind
option in the command? I can't find it referenced in the version 2 file reference.
It's not just macOS I have this problem on, I get it with Ubuntu too:
$ uname -a && docker -v
Linux dev 4.10.0-26-generic #30-Ubuntu SMP Tue Jun 27 09:30:12 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Docker version 17.06.0-ce, build 02c1d87
$ docker run -d --name=dev-consul consul
43247e55be1ac1235252eedbfa37cc412ed6c10973dc053931f3be3f864dad5d
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43247e55be1a consul "docker-entrypoint..." 3 seconds ago Up 2 seconds 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp dev-consul
$ docker inspect dev-consul | grep IPAddress
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.2",
"IPAddress": "172.17.0.2",
$ docker run -d consul agent -dev -join=172.17.0.2
a44961aa65405a589c57c12dee2e6f5089c1fa11f77ca64be27920a010054d65
$ docker run -d consul agent -dev -join=172.17.0.2
4cbd2ba573526a5c478c6693ed5c3c164b198b4e42482d51df29754c5120d460
$ docker exec -t dev-consul consul members
Node Address Status Type Build Protocol DC
43247e55be1a 127.0.0.1:8301 alive server 0.8.5 2 dc1
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43247e55be1a consul "docker-entrypoint..." 46 seconds ago Up 46 seconds 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp dev-consul
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4cbd2ba57352 consul "docker-entrypoint..." 20 seconds ago Exited (1) 19 seconds ago practical_mestorf
a44961aa6540 consul "docker-entrypoint..." 22 seconds ago Exited (1) 21 seconds ago competent_liskov
43247e55be1a consul "docker-entrypoint..." 51 seconds ago Up 50 seconds 8300-8302/tcp, 8500/tcp, 8301-8302/udp, 8600/tcp, 8600/udp dev-consul
$ docker logs practical_mestorf
==> Starting Consul agent...
==> Joining cluster...
==> 1 error(s) occurred:
* Failed to join 172.17.0.2: dial tcp 172.17.0.2:8301: getsockopt: connection refused
$ docker logs competent_liskov
==> Starting Consul agent...
==> Joining cluster...
==> 1 error(s) occurred:
* Failed to join 172.17.0.2: dial tcp 172.17.0.2:8301: getsockopt: connection refused
$ docker logs dev-consul
==> Starting Consul agent...
==> Consul agent running!
Version: 'v0.8.5'
Node ID: 'e4509b0e-f883-f671-6201-9249d69108bf'
Node name: '43247e55be1a'
Datacenter: 'dc1'
Server: true (bootstrap: false)
Client Addr: 0.0.0.0 (HTTP: 8500, HTTPS: -1, DNS: 8600)
Cluster Addr: 127.0.0.1 (LAN: 8301, WAN: 8302)
Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
==> Log data will now stream in as it occurs:
2017/07/01 06:51:25 [DEBUG] Using random ID "e4509b0e-f883-f671-6201-9249d69108bf" as node ID
2017/07/01 06:51:25 [INFO] raft: Initial configuration (index=1): [{Suffrage:Voter ID:127.0.0.1:8300 Address:127.0.0.1:8300}]
2017/07/01 06:51:25 [INFO] raft: Node at 127.0.0.1:8300 [Follower] entering Follower state (Leader: "")
2017/07/01 06:51:25 [INFO] serf: EventMemberJoin: 43247e55be1a 127.0.0.1
2017/07/01 06:51:25 [INFO] consul: Adding LAN server 43247e55be1a (Addr: tcp/127.0.0.1:8300) (DC: dc1)
2017/07/01 06:51:25 [INFO] serf: EventMemberJoin: 43247e55be1a.dc1 127.0.0.1
2017/07/01 06:51:25 [INFO] agent: Started DNS server 0.0.0.0:8600 (udp)
2017/07/01 06:51:25 [INFO] consul: Handled member-join event for server "43247e55be1a.dc1" in area "wan"
2017/07/01 06:51:25 [INFO] agent: Started DNS server 0.0.0.0:8600 (tcp)
2017/07/01 06:51:25 [INFO] agent: Started HTTP server on [::]:8500
2017/07/01 06:51:25 [WARN] raft: Heartbeat timeout from "" reached, starting election
2017/07/01 06:51:25 [INFO] raft: Node at 127.0.0.1:8300 [Candidate] entering Candidate state in term 2
2017/07/01 06:51:25 [DEBUG] raft: Votes needed: 1
2017/07/01 06:51:25 [DEBUG] raft: Vote granted from 127.0.0.1:8300 in term 2. Tally: 1
2017/07/01 06:51:25 [INFO] raft: Election won. Tally: 1
2017/07/01 06:51:25 [INFO] raft: Node at 127.0.0.1:8300 [Leader] entering Leader state
2017/07/01 06:51:25 [INFO] consul: cluster leadership acquired
2017/07/01 06:51:25 [DEBUG] consul: reset tombstone GC to index 3
2017/07/01 06:51:25 [INFO] consul: member '43247e55be1a' joined, marking health alive
2017/07/01 06:51:25 [INFO] consul: New leader elected: 43247e55be1a
2017/07/01 06:51:26 [INFO] agent: Synced service 'consul'
2017/07/01 06:51:26 [DEBUG] agent: Node info in sync
2017/07/01 06:52:08 [DEBUG] http: Request GET /v1/agent/members (235.968µs) from=127.0.0.1:57646
Any solution? I have same issue on Ubuntu 16.04
docker logs goofy_dijkstra ==> Starting Consul agent... ==> Joining cluster... ==> 1 error(s) occurred:
Hello, Same same here :
2017-07-11T09:55:55.067218300Z * Failed to join 172.17.0.2: dial tcp 172.17.0.2:8301: getsockopt: connection refused
on Windows 10 $ docker-machine -v && docker -v docker-machine version 0.12.0, build 45c69ad Docker version 17.06.0-ce, build 02c1d87
I confirm it's working with the tag v0.6.4 but not from the 0.7.2..... with the bind 0.0.0.0 it's working as well.
Can u try --net=host
The following works (sets up a three-node cluster, allowing connection to the html-interface on local ports 8500, 8501, 8502)
docker run -d -p 8500:8500 consul consul agent -data-dir=/consul/data -config-dir=/consul/config -dev -client=0.0.0.0 -bind=0.0.0.0
docker run -d -p 8501:8500 consul consul agent -data-dir=/consul/data -config-dir=/consul/config -dev -client=0.0.0.0 -bind=0.0.0.0 -join 172.17.0.2
docker run -d -p 8502:8500 consul consul agent -data-dir=/consul/data -config-dir=/consul/config -dev -client=0.0.0.0 -bind=0.0.0.0 -join 172.17.0.2
I can make it work based on @martinkoch-geniebelt suggestion above. Thx. I removed some of the parameters, to have a smaller (minimal ?) setup that can actually start and connect. I have fixed the version to 0.9.2 so its easier to reproduce, and added a test matrix below.
Run this in 3 terminals and you should see nice connects
docker run --name --rm dev-consul --rm consul:0.9.2 consul agent -dev -bind=0.0.0.0
docker run --rm -P consul:0.9.2 agent -dev -join=172.17.0.2 -bind=0.0.0.0
docker run --rm -P consul:0.9.2 agent -dev -join=172.17.0.2 -bind=0.0.0.0
and be able to do something like this afterwards
$ docker exec dev-consul consul members
Node Address Status Type Build Protocol DC
06a4d5df14f0 172.17.0.3:8301 alive server 0.9.2 2 dc1
8e43668e2c18 172.17.0.4:8301 alive server 0.9.2 2 dc1
b15f30cda3d7 172.17.0.2:8301 alive server 0.9.2 2 dc1
I tried it with a number of versions.
VERSION | Note |
---|---|
0.7.0 | Works |
0.7.5 | Works |
0.8.0 | Works, but you have to provide a unique id yourself (see *A) |
0.8.3 | Works, but you have to provide a unique id yourself (see *A) |
0.8.1 | Works, but you have to provide a unique id yourself (see *A) |
0.8.4 | Works, but you have to provide a unique id yourself (see *A) |
0.9.2 | Works |
*A if you want, you can provide a unique id on the commandline with -node-id=$(uuidgen | awk '{print tolower($0)}')
You nice consul developers. Thanks for a great product. (@slackpad ?) - would it be an idea to update the "Running consul for Development" part of the documentation to use this approach instead so newcommers have a working "Hello Docker-Consul World" example to play with ? (I can do it if you think its a good idea, just let me know).
NB:I tried with multiple docker versions. The error does not seem to be related to docker itself. I run this on an ubuntu 17.04 with a Docker version 17.06.0-ce, build 02c1d87 if that is of interest to anyone.
docker run -d --rm --name dev-consul consul:latest agent -dev -client=0.0.0.0 -bind=0.0.0.0 docker run -d --rm -P consul:latest agent -dev -join=172.17.0.2 -client=0.0.0.0 -bind=0.0.0.0 docker run -d --rm -P consul:latest agent -dev -join=172.17.0.2 -client=0.0.0.0 -bind=0.0.0.0
it work on consul:latest docker images.