对于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:~#
 
 

046、创建Docker Machine(2019-03-11 周一)的更多相关文章

  1. 2019.03.11 COGS2652 秘术(天文密葬法)(分数规划+长链剖分)

    传送门 题意:nnn个点的树,每个点两个值a,ba,ba,b,问长度为mmm的路径∑ai∑bi\frac{\sum a_i}{\sum b_i}∑bi​∑ai​​的最大值. 思路:一眼要01分数规划, ...

  2. 2019.03.11 bzoj4813: [Cqoi2017]小Q的棋盘(贪心)

    传送门 考虑最后所有走过的点构成的树,显然除了最长链走一遍以外每条轻链都走两遍. 于是求一波最长链搞一搞就完了. 注意几个小细节特判qwq 代码: #include<bits/stdc++.h& ...

  3. Docker Machine v1.11.2安装与使用

    官方文档:Docker Machine 官方文档:Docker Toolbox boot2docker安装包官网下载链接:Docker Toolbox-1.11.1b.exe 此安装包包含的“boot ...

  4. 用 Docker Machine 创建 Azure 虚拟主机

    搭建环境向来是一个重复造轮子的过程,Docker Machine 则把用户搭建 Docker 环境的各种方案汇集在了一起.笔者在<Docker Machine 简介>一文中演示了使用 Do ...

  5. Docker Machine 管理-创建machine(16)

    对于 Docker Machine 来说,术语 Machine 就是运行 docker daemon 的主机.“创建 Machine” 指的就是在 host 上安装和部署 docker.先执行 doc ...

  6. 2.docker machine 创建 包含 docker 的 linux 虚拟机

    1. 启动 从https://github.com/boot2docker/boot2docker/releases下载iso到~/.docker/machine/cache/里 docker-mac ...

  7. DOCKER 学习笔记7 Docker Machine 在阿里云实例化ECS 以及本地Windows 实例化虚拟机实战

    前言 通过以上6小节的学习,已经可以使用DOCKER 熟练的部署应用程序了.大家都可以发现使用 DOCKER 带来的方便之处,因为现在的话,只是在一台服务器上部署,这样部署,我们只需要一条命令,需要的 ...

  8. DOCKER 学习笔记7 Docker Machine 建立虚拟机实战,以及错误总结

    前言 通过以上6小节的学习,已经可以使用DOCKER 熟练的部署应用程序了.大家都可以发现使用 DOCKER 带来的方便之处,因为现在的话,只是在一台服务器上部署,这样部署,我们只需要一条命令,需要的 ...

  9. Create a new Docker Machine with the Hyper-V driver

    docker-machine就是docker工具集中提供的用来管理容器化主机的工具,用来管理运行在不同环境的主机,包括:本地虚拟机,远程虚拟机,公有云中的虚拟机都可以通过一个命令统一进行管理. 01. ...

随机推荐

  1. Hdoj 1159.Common Subsequence 题解

    Problem Description A subsequence of a given sequence is the given sequence with some elements (poss ...

  2. MongoDB 数据库创建删除、表创建删除、数据增删改查

    一.管理 mongodb 数据库:mongo 查看所有数据库列 表 show dbs 二. 创建数据库 创建 数据库 use student 如果真的想把这个数据库创建成功,(collections) ...

  3. 哈尔滨工程大学ACM预热赛 G题 A hard problem(数位dp)

    链接:https://ac.nowcoder.com/acm/contest/554/G Now we have a function f(x): int f ( int x ) {     if ( ...

  4. Ubuntu16.04下的NetCore环境搭建(附录含Ubuntu 18.04 安装 NetCore2.1)

    跨平台系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#linux VSCode安装:http://www.cnblogs.com/dunitia ...

  5. POJ--3614 Sunscreen(贪心)

    题目 3614 Sunscreen 2500*2500直接排序暴力贪心 #include<iostream> #include<cstring> #include<alg ...

  6. 浅析 @PathVariable 和 @RequestParam(转发,非原创)

    首先 上两个地址:地址①http://localhost:8989/SSSP/emps?pageNo=2地址②http://localhost:8989/SSSP/emp/7如果想获取地址①中的 pa ...

  7. sshd启动报错Could not load host key

    ~ # /usr/sbin/sshd Could not load host key: /etc/ssh/ssh_host_rsa_key Could not load host key: /etc/ ...

  8. 【洛谷P3917】异或序列

    题目大意:给定一个长度为 N 的序列,每个位置有一个权值,求 \[\sum\limits_{1\le i\le j\le n}(a_i\oplus a_{i+1}...\oplus a_j)\] 的值 ...

  9. /etc/profile

    PS1:就是用户平时的提示符. PS2:第一行没输完,等待第二行输入的提示符. Linux系统提示符是用系统变量PS1来定义的.一般系统默认的形式是:[username@host 工作目录]$. 用e ...

  10. C# 中使用 ThoughtWorks.QRCode.dll 生成指定尺寸和边框宽度的二维码

    本文介绍在 C# 中使用 ThoughtWorks.QRCode.dll 生成指定尺寸和边框宽度的二维码.网上文章大多只是简单介绍内置参数的设置,根据我的使用目的,增加了自定义目标二维码图片尺寸和白边 ...