docker-machine使用 - Go语言中文社区

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)


版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/Aggressive_snail/article/details/89474508
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢