说明:
本文环境:CentOS 7
```
1、#ip地址配置(在xnode2的基础上)
[root@xnode2 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eno16777736TYPE=EthernetBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noNAME=eno16777736UUID=0c189275-81a1-4c21-84b8-e72af745cb09DEVICE=eno16777736ONBOOT=yesIPADDR=192.168.200.12GATEWAY=192.168.200.2NETMASK=255.255.255.0DNS1=8.8.8.8
```
2、关闭防火墙
```
[root@xnode2 ~]# systemctl stop firewalld[root@xnode2 ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
```
3、关闭selinux
```
[root@xnode2 ~]# vi /etc/selinux/configSELINUX=disabled
```
4、关机克隆,crt链接克隆机
```
[root@xnode2 ~]# hostnamectl set-hostname docker1[root@xnode2 ~]# bash
```
5、配置centos源
使用阿里云的镜像源https://developer.aliyun.com/
curl -o /etc/yum.repos.d/CentOS-Base.repo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
```
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo[root@docker1 yum.repos.d]# yum install wget -y[root@docker1 yum.repos.d]# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
```
如果以上centos源过期,按照以下步骤拉取:
a、百度搜索"阿里源"
阿里源链接:centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站 (aliyun.com)
b、下滑选择复制
6、删除原有的docker(如果已安装执行下面)
```
[root@docker-server ~]# yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-selinux \docker-engine-selinux \docker-engine
```
7、安装docker的依赖
```
yum install -y yum-utils device-mapper-persistent-data lvm2
```
8、配置yum源
```
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```
9、安装指定版本的docker
```
#查看docker-ce支持版本
yum list docker-ce --showduplicates|sort -ryum install docker-ce-18.09.6 docker-ce-cli-18.09.6 -y
```
10、docker版本
```
[root@docker1 ~]# docker version
显示版本号如下:
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77156
Built: Sat May 4 02:34:58 2019
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
```
11、启动docker
```
[root@docker1 ~]# systemctl start docker[root@docker1 ~]# systemctl enable dockerCreated symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
```
12、配置docker的加速器
```
[root@docker1 ~]# vi /etc/docker/daemon.json[root@docker1 ~]# cat /etc/docker/daemon.json{"registry-mirrors": ["https://7hw6x2is.mirror.aliyuncs.com"]}[root@docker1 ~]# systemctl daemon-reload[root@docker1 ~]# systemctl restart docker
```
##### 本地安装方式&FTP方式
### 继续操作
克隆xnode2
1、更改主机名
```
[root@xnode2 ~]# hostnamectl set-hostname docker3[root@xnode2 ~]# bash
```
2、在之前的docker1上配置ftp服务
```
yum install vsftpd -yvi /etc/vsftpd/vsftpd.conf
#增加
anon_root=/opt
systemctl start vsftpd
systemctl enable vsftpd
```
3、在docker3上通过ftp方式配置yum源
```
[root@docker3 ~]# vi /etc/yum.repos.d/local.repo
添加以下内容
[docker]
name=docker
baseurl=ftp://192.168.200.12/Docker#其中docker1的ip地址为192.168.200.12
gpgcheck=0
enabled=1
```
4、docker3上安装docker
```
yum install -y yum-utils device-mapper-persistent-data lvm2yum install docker-ce -y
```
5、docker3上启动docker
```
[root@docker3 ~]# systemctl start docker[root@docker3 ~]# systemctl enable dockerCreated symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
```
6、配置docker的加速器
```
[root@docker3 ~]# vi /etc/docker/daemon.json[root@docker3 ~]# cat /etc/docker/daemon.json{"registry-mirrors": ["https://7hw6x2is.mirror.aliyuncs.com"]}[root@docker3 ~]# systemctl daemon-reload[root@docker3 ~]# systemctl restart docker
```