docker-machine使用

实现目标

  • 使用docker-machine在远程主机安装docker-ce(17.03.2)
  • 使用docker-machine登录并管理远程主机的docker

准备环境

  • 时间:2019年4月23日
  • 本地主机mint18
  • 远程主机ubuntu16.04

安装docker-machine

安装手册

docker-machine命令自动补全

配置环境

  • 配置ssh登录远程设备
    追加本地主机的~/.ssh/id_rsa.pub到远程主机的~/.ssh/authorized_key

  • 在远程主机上配置登录用户NOPASSWD权限
    在这里插入图片描述

创建docker

在本地主机执行命令如下命令

docker-machine create -d generic --generic-ip-address=10.10.11.137 --generic-ssh-user=micro --generic-ssh-key ~/.ssh/id_rsa --engine-install-url="https://raw.githubusercontent.com/rancher/install-docker/master/17.03.2.sh" micro
  • -d generic 驱动类型
  • --generic-ip-address 10.10.11.137 远程主机ip
  • --generic-ssh-user=micro ssh用户名
  • --generic-ssh-key ~/.ssh/id_rsa ssh使用的本地验证文件
  • --engine-install-url="https://raw.githubusercontent.com/rancher/install-docker/master/17.03.2.sh" 17.03.2docker安装脚本

其他版本安装脚本

gws@gws-TP450:~$ docker-machine create -d generic --generic-ip-address=10.10.11.137 --generic-ssh-user=micro --generic-ssh-key ~/.ssh/id_rsa --engine-install-url="https://raw.githubusercontent.com/rancher/install-docker/master/17.03.2.sh" micro
Running pre-create checks...
Creating machine...
(micro) Importing SSH key...
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 ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env micro

查看

gws@gws-TP450:~$ docker-machine ls
NAME        ACTIVE   DRIVER       STATE     URL                       SWARM   DOCKER        ERRORS
micro       -        generic      Running   tcp://10.10.11.137:2376           v17.03.2-ce   
rancherOS   -        virtualbox   Stopped                                     Unknown    
gws@gws-TP450:~$ eval $(docker-machine env micro)
gws@gws-TP450:~$ docker version
Client:
 Version:      17.03.2-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   f5ec1e2
 Built:        Tue Jun 27 03:35:14 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.2-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   f5ec1e2
 Built:        Tue Jun 27 03:35:14 2017
 OS/Arch:      linux/amd64
 Experimental: false
gws@gws-TP450:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
gws@gws-TP450:~$ eval $(docker-machine env --unset)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值