一、Docker引擎安装
【Docker安装】
1.配置Docker源,升级内核
yum upgrade -y
2.配置防火墙和SELinux
systemctl stop firewalld && systemctl disable firewalld
iptables -t filter -F
iptables -t filter -X
iptables -t filter -Z
/usr/sbin/iptables-save
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
reboot
3.开启路由转发
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
modprobe br_netfilter
4.Docker引擎安装
yum install -y yum-utils device-mapper-p*
yum install -y device-ce*
5.启动Docker,查看系统信息
systemctl daemon-reload
systemctl restart docker
docker info
二、Docker仓库的搭建
【Docker仓库使用】:配仓库,打标记,推送
1.后台(-d)启动容器,映射从右往左(-v),–restart=always(重启docker时重启容器)
docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest
2.配置私有仓库
vi /etc/docker/daemon.json
{“insecure-registries”:[“仓库IP地址:5000”]}
systemctl restart docker
docker tag:标记镜像 (公式:docker tag 镜像 镜像仓库IP地址:5000/镜像)
docker tag centos:latest 仓库IP地址:5000/centos:latest
3.上传标记的镜像
docker push 镜像仓库IP地址:5000/镜像
4.查看被推送的镜像
curl -L http://镜像仓库IP地址:5000/v2/_catalog
5.slave节点拉取镜像
(1)先配置私有仓库地址
vi /etc/docker/daemon.json
{“insecure-registries”:[“仓库IP地址:5000”]}
systemctl restart docker
(2)拉取镜像
docker pull 镜像仓库IP地址:5000/镜像
三