047、管理Docker Machine(2019-03012 周二)

参考https://www.cnblogs.com/CloudMan6/p/7248188.html     用docker-machine创建machine的过程很简洁,非常适合多主机环境。除此之外,docker machine也提供了一些子命令方便对machine进行管理。其中最常见的就是无需登录到machine就能执行docker相关操作。     [root@dm03 ~]# docker-machine env host1 export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://123.58.8.20:2376" export DOCKER_CERT_PATH="/root/.docker/machine/machines/host1" export DOCKER_MACHINE_NAME="host1" # Run this command to configure your shell: # eval $(docker-machine env host1) [root@dm03 ~]# eval $(docker-machine env host1) [root@dm03 ~ [host1]]# docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE [root@dm03 ~ [host1]]# docker pull busybox Using default tag: latest latest: Pulling from library/busybox 697743189b6d: Pull complete Digest: sha256:061ca9704a714ee3e8b80523ec720c64f6209ad3f97c0ff7cb9ec7d19f15149f Status: Downloaded newer image for busybox:latest [root@dm03 ~ [host1]]# docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE busybox             latest              d8233ab899d4        3 weeks ago         1.2MB [root@dm03 ~ [host1]]# docker-machine env host2 export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://123.58.8.75:2376" export DOCKER_CERT_PATH="/root/.docker/machine/machines/host2" export DOCKER_MACHINE_NAME="host2" # Run this command to configure your shell: # eval $(docker-machine env host2) [root@dm03 ~ [host1]]# eval $(docker-machine env host2) [root@dm03 ~ [host2]]# docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE [root@dm03 ~ [host2]]# docker pull httpd Using default tag: latest latest: Pulling from library/httpd f7e2b70d04ae: Pull complete 84006542c688: Pull complete dae6fe3c5e81: Pull complete 33fc493aff90: Pull complete 9a4113020573: Pull complete Digest: sha256:20ead958907f15b638177071afea60faa61d2b6747c216027b8679b5fa58794b Status: Downloaded newer image for httpd:latest [root@dm03 ~ [host2]]# docker images REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE httpd               latest              2d1e5208483c        6 days ago          132MB   [root@dm03 ~]# docker-machine upgrade host1 host2 Waiting for SSH to be available... Waiting for SSH to be available... Detecting the provisioner... Detecting the provisioner... Upgrading docker... Upgrading docker... Restarting docker... Restarting docker...   [root@dm03 ~]# docker-machine config host1 --tlsverify --tlscacert="/root/.docker/machine/machines/host1/ca.pem" --tlscert="/root/.docker/machine/machines/host1/cert.pem" --tlskey="/root/.docker/machine/machines/host1/key.pem" -H=tcp://123.58.8.20:2376 [root@dm03 ~]# docker-machine config host2 --tlsverify --tlscacert="/root/.docker/machine/machines/host2/ca.pem" --tlscert="/root/.docker/machine/machines/host2/cert.pem" --tlskey="/root/.docker/machine/machines/host2/key.pem" -H=tcp://123.58.8.75:2376   [root@dm03 ~]# docker-machine scp 1.sh host2:/root/    #    scp功能 1.sh                                                                                                       100% 1145     1.1KB/s   00:00       [root@dm03 ~]# eval $(docker-machine env host1)    #    如何退出 [root@dm03 ~ [host1]]# eval $(docker-machine env -u ) [root@dm03 ~]#     注意:docker-machine stop/start/restart 是对docker host的操作系统进行操作,而非docker daemon    
上一篇:docker基础篇(一)补


下一篇:第二章 ELKstack部署及配置