LoginSignup
0

More than 5 years have passed since last update.

Docker Swarm モード利用時の Proxy 設定

Last updated at Posted at 2018-11-11

Docker Swarm モードを用いてクラスタを構築する際、worker node は追加できるのに、 manager node の追加が行えなかったためメモ。

Docker Daemon への Proxy 設定

Proxy 配下で Docker を利用する際、 docker pull / push が Proxy に阻まれてしまうため設定を行う必要があります。

docker docs を参考に、 /etc/systemd/system/docker.service.d/https-proxy.conf に設定を記述します。

http-proxy.conf
[Service]    
Environment="HTTP_PROXY=http://proxy.example.com:80/" "HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1"

Swarm モードを利用する際にハマった点なのですが、 NO_PROXY に 各 Node の IP アドレスを記述しておく必要があります。
Docker の Forum に同じ状況に陥った方がいました。
Manager node の IP のみで大丈夫な気もしますが、

We added all our Docker IP addresses to the no_proxy variable, and then rebooted all Docker nodes. Once that was done, we were able to join as manager again.

とあるので、 worker も含めた全 node を列挙していきます。( CIDR 記法やワイルドカードは使えません...)

http-proxy.conf
[Service]    
Environment="HTTP_PROXY=http://proxy.example.com:80/" "HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,192.168.1.X,192.168.1.Y,..."

記述できれば

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

でDockerを再起動します。

あとは docker swarm join ... を実行すれば worker node 、 manager node 共に追加することができます。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0