# マシン再起動の後 ~/H/docker4 ❯❯❯ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS myvm1 - virtualbox Stopped Unknown myvm2 - virtualbox Stopped Unknown # DOCKER* の環境変数は設定されていない状態 ~/H/docker4 ❯❯❯ env|ag DOCKER # 前述の2つのVM(Swarm の node)を起動する ~/H/docker4 ❯❯❯ docker-machine restart myvm1 Restarting "myvm1"... Starting "myvm1"... (myvm1) Check network to re-create if needed... (myvm1) Waiting for an IP... Machine "myvm1" was started. Waiting for SSH to be available... Detecting the provisioner... Waiting for SSH to be available... Detecting the provisioner... Restarted machines may have new IP addresses. You may need to re-run the `docker-machine env` command. ~/H/docker4 ❯❯❯ docker-machine restart myvm2 ⏎ Restarting "myvm2"... Starting "myvm2"... (myvm2) Check network to re-create if needed... (myvm2) Waiting for an IP... Machine "myvm2" was started. Waiting for SSH to be available... Detecting the provisioner... Waiting for SSH to be available... Detecting the provisioner... Restarted machines may have new IP addresses. You may need to re-run the `docker-machine env` command. # docker-machine の起動状態を確認 ~/H/docker4 ❯❯❯ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS myvm1 - virtualbox Running tcp://192.168.99.100:2376 v18.05.0-ce myvm2 - virtualbox Running tcp://192.168.99.101:2376 v18.05.0-ce ~/H/docker4 ❯❯❯ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ~/H/docker4 ❯❯❯ docker stack ls Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again. ~/H/docker4 ❯❯❯ docker-machine env myvm1 ⏎ export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.99.100:2376" export DOCKER_CERT_PATH="/Users/satoru/.docker/machine/machines/myvm1" export DOCKER_MACHINE_NAME="myvm1" # Run this command to configure your shell: # eval $(docker-machine env myvm1) # 手元から myvm1(swarm manager)の中にはいる ~/H/docker4 ❯❯❯ eval $(docker-machine env myvm1) # myvm1(swarm manager)の中でスタックの確認 ~/H/docker4 ❯❯❯ docker stack ls NAME SERVICES getstartedlab 1 # myvm1(swarm manager)の中でコンテナ稼働中。 ~/H/docker4 ❯❯❯ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b559f4feca31 me/get-started:part2 "python app.py" 2 minutes ago Up 2 minutes 80/tcp getstartedlab_web.1.jibwht3xvh0nccpanxhe0e7f3 2f912f6c0e01 me/get-started:part2 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.3.8bk7vrtv5s20l14p9bv03l3x7 0731ecaad1ed me/get-started:part2 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.2.tr8aftd3w451d4twq8s39rndr ~/H/docker4 ❯❯❯
アプリが稼働している。 host が myvm1 gyazo.com
host が myvm2 gyazo.com
~/H/docker4 ❯❯❯ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b559f4feca31 me/get-started:part2 "python app.py" 2 minutes ago Up 2 minutes 80/tcp getstartedlab_web.1.jibwht3xvh0nccpanxhe0e7f3 2f912f6c0e01 me/get-started:part2 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.3.8bk7vrtv5s20l14p9bv03l3x7 0731ecaad1ed me/get-started:part2 "python app.py" 3 minutes ago Up 3 minutes 80/tcp getstartedlab_web.2.tr8aftd3w451d4twq8s39rndr
停止する
~/H/docker4 ❯❯❯ docker-machine stop myvm2 Stopping "myvm2"... Machine "myvm2" was stopped. ~/H/docker4 ❯❯❯ docker-machine stop myvm1 Stopping "myvm1"... Machine "myvm1" was stopped.