码迷,mamicode.com
首页 > 系统相关 > 详细

docker machine

时间:2018-11-17 20:59:11      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:class   运行   size   errors   wait   bsp   mac   image   env   

环境

docker-machine主机:192.168.1.9  

docker主机:192.168.1.10  

步骤:

安装docker-machine

 

[root@master ~]# curl -L https://github.com/docker/machine/releases/download/v0.14.0/docker-machine-`uname -s`-`uname -m` >/tmp/docker-machine
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    390      0 --:--:--  0:00:01 --:--:--   390
100 26.7M  100 26.7M    0     0  1618k      0  0:00:16  0:00:16 --:--:-- 3622k
[root@master ~]# chmod +x /tmp/docker-machine 
[root@master ~]# cp /tmp/docker-machine /usr/local/bin/docker-machine
[root@master ~]# ll /usr/local/bin/docker-machine 
-rwxr-xr-x 1 root root 28034848 6月  12 15:24 /usr/local/bin/docker-machine
[root@master ~]# docker-machine -v
docker-machine version 0.14.0, build 89b8332

创建ssh密钥对,实现两主机无密登录

[root@node1 ~]# ssh-keygen

[root@node1 ~]# ssh-copy-id 192.168.1.10

创建docker主机,命名host1

[root@node1 ~]# docker-machine create  -d  generic  --generic-ip-address=192.168.1.10  host1

Running pre-create checks...

Creating machine...

(swarm-master) No SSH key specified. Assuming an existing key at the default location.

Waiting for machine to be running, this may take a few minutes...

Detecting operating system of created instance...

Waiting for SSH to be available...

Detecting the provisioner...

Provisioning with centos...

Running...

[root@node1 ~]# docker-machine ls

NAME           ACTIVE   DRIVER    STATE     URL                       SWARM                   DOCKER        ERRORS

host1   -        generic   Running   tcp://192.168.1.10:2376      v17.12.1-ce   

变更docker环境变量

[root@node1 ~]# docker-machine env host1

export DOCKER_TLS_VERIFY="1"

export DOCKER_HOST="tcp://192.168.1.10: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@node1 ~]# eval $(docker-machine env host1)

运行容器查看两端是否同步

[root@node1 ~]# docker run -d busybox

[root@node1 ~]# docker-machine ssh host1

[root@host1 ~]# docker image ls

REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE

busybox                 latest              f6e427c148a7        6 days ago          1.15MB

[root@host1 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                              NAMES

8d9b5005a264        busybox             "sh"                     17 seconds ago      Up 16 seconds ago                                         modest_joliot

[root@host1 ~]# exit

[root@node1 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                         PORTS                              NAMES

8d9b5005a264        busybox             "sh"                    57seconds ago      Up 16 seconds ago                                         modest_joliot

镜像容器同步测试成功

docker machine

标签:class   运行   size   errors   wait   bsp   mac   image   env   

原文地址:https://www.cnblogs.com/chenyishi/p/9975243.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!