对于Docker Machine来说,属于 Machine 就是运行docker daemon的主机。创建Machine 指的就是在host上安装和部署docker,
 
1、创建machine要求 能够通过ssh没密钥登录远程主机,过程略
 
[root@dm03 ~]# ssh-copy-id -i .ssh/id_rsa.pub 123.58.8.20
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@123.58.8.20's password:
 
Number of key(s) added: 1
 
Now try logging into the machine, with:   "ssh '123.58.8.20'"
and check to make sure that only the key(s) you wanted were added.
 
2、各host配置apt源,包括docker-ce源
 
scp /etc/apt/sources.list 123.58.8.20:/etc/apt/sources.list
 
3、各host修改防火墙,开启tcp 2376
 
ssh 123.58.8.20 'ufw allow 2376'
 
4、安装docker
 
[root@dm03 ~]# docker-machine create --driver generic --generic-ip-address 123.58.8.20 host1
Running pre-create checks...
Creating machine...
(host1) No SSH key specified. Assuming an existing key at the default location.    # ssh登录到远程主机
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)...    # 安装docker
Installing Docker...
Copying certs to the local machine directory...    # 拷贝证书
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...    # 配置docker
Checking connection to Docker...    # 启动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 host1
 
[root@dm03 ~]# docker-machine ls
NAME    ACTIVE   DRIVER    STATE     URL                      SWARM   DOCKER     ERRORS
host1   -        generic   Running   tcp://123.58.8.20:2376           v18.09.3   
host2   -        generic   Running   tcp://123.58.8.75:2376           v18.09.3   
 
5、如果安装docker的时候报证书相关错误可以执行一下命令进行修复
 
docker-machine regenerate-certs host1
 
 
 
登录到一台docker host上可以看到主机名已经修改成了host2 ,且docker配置文件开启了远程连接,并启用了tls安全认证和加密
 
root@host2:~# hostname    
host2
root@host2:~# cat /etc/systemd/system/docker.service.d/10-machine.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver overlay2 --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic
Environment=
root@host2:~#
 
 

最新文章

  1. C#操作mysql数据库
  2. MSXML应用总结
  3. 3.2 ARM指令分类学习
  4. setTimeout不断重复执行
  5. Arduino101学习笔记(六)—— 高级IO
  6. Nginx简介及配置实用
  7. 7款超具个性的HTML5播放器
  8. eclipse中,把java函数代码折叠/展开
  9. DWM1000 自动应答代码实现与实例
  10. win8.1安装win64_11gR2_database_2of2 【INS-13001]】环境不满足最低要求问题
  11. Scala-Unit6-final/type关键字、样例类&样例对象
  12. 收集服务器网卡和IP信息
  13. Jenkins结合testng注意事项
  14. Grunt相关
  15. vue教程2-03 vue计算属性的使用 computed
  16. Spring Boot启动流程
  17. 链表的C/C++实现
  18. flex sqlite 操作blog 二进制数据
  19. [洛谷P3174][HAOI2009]毛毛虫
  20. thinkphp 3.2中依靠关联模型来关联三个表

热门文章

  1. flask报错:werkzeug.routing.BuildError: Could not build url for endpoint 'index'. Did you mean 'single' instead?
  2. 【HDU4947】GCD Array (莫比乌斯反演+树状数组)
  3. 搭建web定时任务管理平台
  4. 记OI退役
  5. [FJOI2016]神秘数(脑洞+可持久化)
  6. spring代码异常捕获到logback logging.config=logback-spring.xml文件中不能输出异常e.printStackTrace
  7. 【洛谷P2966】Cow Toll Paths
  8. [ZROJ110][假如战争今天爆发]
  9. 系统API执行没效果,可以检查一下是否与 360安全卫士 有关?!
  10. Python之推导式、生成器表达式