LoginSignup
3
4

More than 5 years have passed since last update.

DockerのGet Started Part4で詰まったところメモ

Posted at

詰まったところとその解決

Create Clasterの段で

$ docker-machine create --driver virtualbox myvm1
$ docker-machine create --driver virtualbox myvm2

を叩いた後,

$ docker-machine ssh myvm1 "docker swarm init"

を叩くと以下のエラーメッセージが出た.

Error response from daemon: could not choose an IP address to advertise since this system has multiple addresses on different interfaces (10.0.2.15 on eth0 and 192.168.99.100 on eth1) - specify one with --advertise-addr

VirtualBoxでホストオンリーアダプターを使用した仮想マシンを作っていたためか,新しく作成した仮想マシンにもこのアダプターが適用されていた.結果,一つのマシンに複数のIPが存在することになったのでdockerがどちらを使えばいいか困ってしまった模様.

"Got an error about needing to use --advertise-addr?" の項には--advertise-addrにIPとポート2377を指定するように書いてある.

IPを調べる.

$ docker-machine ls
NAME    ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
myvm1   -        virtualbox   Running   tcp://192.168.99.100:2376           v17.06.2-ce
myvm2   -        virtualbox   Running   tcp://192.168.99.101:2376           v17.06.2-ce

仮想マシンのIPとポート2377を指定して再度docker swarm initすると

Error response from daemon: advertise address must be a non-zero IP address or network interface (with optional port number)

とエラーが出てうまくいかない.

2377から2376に変更してみる

$ docker-machine ssh myvm1 "docker swarm init --advertise-addr 192.168.99.100:2376"
Swarm initialized: current node (7pti0utyejt72awns372h2cs2) is now a manager.

To add a worker to this swarm, run the following command:

    docker swarm join --token SWMTKN-1-5wzuw5al92i55hdfw6738ge03coversgpj4ow5vv5i6kxhvbgm-7rvnbpdv9mu87i0osy8o9qady 192.168.99.100:2376

To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.

とりあえず初期化ができたので,指示に従ってクラスターにmyvm2を追加しようとしたところまたエラーが出た.

$ docker-machine ssh myvm2 "docker swarm join --token SWMTKN-1-5wzuw5al92i55hdfw6738ge03coversgpj4ow5vv5i6kxhvbgm-7rvnbpdv9mu87i0osy8o9qady 192.168.99.100:2376"
Error response from daemon: rpc error: code = 13 desc = connection error: desc = "transport: remote error: tls: bad certificate"
exit status 1

エラーメッセージで検索すると次の記事がヒット
https://github.com/docker/machine/issues/4064

lupulin commented on 22 Apr
It worked for me this time. I assume you're doing --advertise-addr with the IP and port that's in docker-machine ls. You have to use PORT 2377 per the instructions. Then, it seems to work.

2376->2377に変更して再度join.

$ docker-machine ssh myvm2 "docker swarm join --token SWMTKN-1-5wzuw5al92i55hdfw6738ge03coversgpj4ow5vv5i6kxhvbgm-7rvnbpdv9mu87i0osy8o9qady 192.168.99.100:2377"
This node joined a swarm as a worker.

myvm2をworkerとして登録できたっぽい.

何が悪かったのか

デフォルトでlistenするポートとswarm joinで利用するポートが一致していなかった?
チュートリアルでは

Copy the IP address for myvm1 by running docker-machine ls, then run the docker swarm init command again, using that IP and specifying port 2377 (the port for swarm joins) with --advertise-addr

とあるが,swarm initするまではポート2377をlistenしていない気がする.(確認していない)

3
4
0

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
3
4