参考
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/machi
nes/host1"
export DOCKER_MACHINE_NAME="host1"
# Run this command to con
figure 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 busy
Box
Using default tag: latest
latest: Pulling from library/busy
Box
697743189b6d: Pull complete
Digest: sha256:061ca9704a714ee3e8b80523ec720c64f6209ad3f97c0ff7cb9ec7d19f15149f
Status: Downloaded newer image for busy
Box:latest
[root@dm03 ~ [host1]]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busy
Box 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/machi
nes/host2"
export DOCKER_MACHINE_NAME="host2"
# Run this command to con
figure 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 con
fig host1
--tl
sverify
--tlscacert="/root/.docker/machine/machi
nes/host1/ca.pem"
--tlscert="/root/.docker/machine/machi
nes/host1/cert.pem"
--tlskey="/root/.docker/machine/machi
nes/host1/key.pem"
-H=tcp://123.58.8.20:2376
[root@dm03 ~]# docker-machine con
fig host2
--tl
sverify
--tlscacert="/root/.docker/machine/machi
nes/host2/ca.pem"
--tlscert="/root/.docker/machine/machi
nes/host2/cert.pem"
--tlskey="/root/.docker/machine/machi
nes/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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。