显然,Docker容器共享相同的UUID。如何在同一个docker主机上为每个容器设置不同的值?
我正在运行一个程序,consul,显然有与具有相同UUID的docker容器有问题抛出此错误:
root@redis-2:/usr/local/bin# consul agent -config-dir /etc/consul.d/ -bind 172.17.0.3 &
[1] 428
root@kkbox-test-redis-2:/usr/local/bin# ==> WARNING: LAN keyring exists but -encrypt given, using keyring
==> Starting Consul agent...
==> Joining cluster...
==> 3 error(s) occurred:
* Failed to join 10.24.5.251: Member 'kkbox-test-redis-1' has conflicting node ID 'ec2484ee-2960-1781-6d95-3bd994e5f3bf' with this agent's ID
* Failed to join 10.24.5.252: Member 'kkbox-test-redis-1' has conflicting node ID 'ec2484ee-2960-1781-6d95-3bd994e5f3bf' with this agent's ID
* Failed to join 10.24.6.251: Member 'kkbox-test-redis-1' has conflicting node ID 'ec2484ee-2960-1781-6d95-3bd994e5f3bf' with this agent's ID
有没有办法在这里更新每个容器中的UUID?:
/proc/sys/kernel/random/boot_id
答案 0 :(得分:1)
将-disable-host-node-id
传递给consul agent ...
,并且consul将在启动时生成随机节点ID(而不是从/proc/sys/kernel/random/boot_id
生成)。
像这样:
consul agent -disable-host-node-id -config-dir /etc/consul.d/ -bind 172.17.0.3 &
或者,您可以自己生成节点ID并通过-node-id
标志传递它。
另见Consul join broken in containerized Servers run on same node