I am unable to connect a second manager node to my Swarm when using an http proxy


#1

When I try to connect a second manager node to my Docker Swarm when using an HTTP proxy I get the following error:

Does this machine require a proxy to access the Internet? (y/N) y
Enter desired HTTP proxy address: http://10.128.0.3:3128
The installer will use the proxy at 'http://10.128.0.3:3128'
Joining the swarm
Error response from daemon: manager stopped: can't initialize raft node: rpc error: code = Unavailable desc = grpc: the connection is unavailable
Failed to join the swarm cluster.
It may be possible to re-run this installer with the flags -swarm-advertise-addr and -swarm-listen-addr to resolve the problem.

#2

Docker must be configured not to use the HTTP proxy for all managers when connecting via internal IP addresses. To fix this you must add the advertise addresses of all Swarm managers to each manager’s NO_PROXY variable.

The /swarm-init and /swarm-join scripts scripts can be run with the additional-no-proxy flag set to a comma-delimited list of all manager IP addresses in the Swarm.

For example:

curl -sSL https://get.replicated.com/swarm-init | sudo bash -s \
    http-proxy=http://10.128.0.3:3128 \
    additional-no-proxy=10.128.0.39,10.128.0.6

and

curl -sSL https://get.replicated.com/swarm-join | sudo bash -s \
    swarm-master-address=10.128.0.39:2377 \
    swarm-token=[redacted] \
    daemon-registry-address=10.128.0.39:9874 \
    ca=[redacted] \
    http-proxy=http://10.128.0.3:3128 \
    additional_no_proxy=10.128.0.39,10.128.0.6,127.0.0.1,172.17.0.1,localhost

Additional managers can be added later by manually editing the Docker NO_PROXY environment variable and restarting the Docker service.

You can change this by editing the file /etc/systemd/system/docker.service.d/http-proxy.conf. You will then need to reload the systemd service configuration (systemctl daemon-reload) and restart the Docker service (systemctl restart docker). More information can be found here on configuring the Docker service.