在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
一、docker machine概要 Docker Machine发布之前,你可能会遇到以下问题: ①你需要登录主机,按照主机及操作系统特有的安装以及配置步骤安装Docker,使其能运行Docker容器。 Docker Machine的出现解决了以上问题。 ①Docker Machine简化了部署的复杂度,无论是在本机的虚拟机上还是在公有云平台,只需要一条命令便可搭建好Docker主机 二、docker machine在远程主机部署docker 环境:
步骤: ①更新curl yum update curl -y ②安装docker-machine 安装可参考docker-machine官网 linux下载路径: 复制代码 代码如下: curl -L https://github.com/docker/mac...uname -s-uname -m >/tmp/docker-machine && install /tmp/docker-machine /usr/local/bin/docker-machine
按需求直接复制粘贴安装即可 [root@node1 ~]# docker-machine -v docker-machine version 0.13.0, build 9ba6da9 ③创建ssh密钥对,实现两主机无密登录 [root@node1 ~]# ssh-keygen [root@node1 ~]# ssh-copy-id 192.168.1.10 ④为本地下载更多镜像源,避免在创建machine时找不到软件包 [root@node1 ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/rep... #此为阿里云centos7镜像源 [root@node1 ~]# yum install epel-release #第三方源 ⑤开启machine通讯端口 [root@node1 ~]# firewall-cmd --add-port=2376/tcp --permanent [root@node1 ~]# firewall-cmd --reload ⑥创建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 镜像容器同步测试成功 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持极客世界。 |
请发表评论