How to keep IP addresses in dockerized Consul cluster on one node after reboot
I am new to Docker and Consul and am now trying to create a local Consul cluster consisting of 3 docked nodes. I am using a progrium/consul
Docker image and go through the entire tutorial and examples described.
The cluster works fine until a restart / reboot occurs.
Here is mine docker-compose.yml
:
---
node1:
command: "-server -bootstrap-expect 3 -ui-dir /ui -advertise 10.67.203.217"
image: progrium/consul
ports:
- "10.67.203.217:8300:8300"
- "10.67.203.217:8400:8400"
- "10.67.203.217:8500:8500"
- "10.67.203.217:8301:8301"
- "10.67.203.217:8302:8302"
- "10.67.203.217:8301:8301/udp"
- "10.67.203.217:8302:8302/udp"
- "172.17.42.1:53:53/udp"
restart: always
node2:
command: "-server -join 10.67.203.217"
image: progrium/consul
restart: always
node3:
command: "-server -join 10.67.203.217"
image: progrium/consul
restart: always
registrator:
command: "consul://10.67.203.217:8500"
image: "progrium/registrator:latest"
restart: always
I get a message like:
[ERR] raft: Failed to make RequestVote RPC to 172.17.0.103:8300: dial tcp 172.17.0.103:8300: no route to host
which is obviously due to the new IP, my nodes 2 and 3 are getting after restarting. So can this be prevented? Read about references and environment variables, but it looks like those variables also don't update after reboot.
source to share
I had the same problem until I read that when loading a containerized consul node there is an issue with ARP table caching.
As far as I know there are 2 ways:
- Start your container with --net = host
- Clear ARP table before reloading container: run docker --net = host --privileged --rm cap10morgan / conntrack -F
The owner (Jeff Lindsay) told me they are redrawing the entire container with this inline fix, unfortunately not.
source to share