1.关闭防火墙和selinux
iptables -F
iptables -X
iptables -Z
iptables -save
2.修改内核配置
uname -r
vi /etc/sysctl.d/docker.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.ip_forward = 1
sysctl -p /etc/sysctl.d/docker.conf
modprobe br_netfilter
sysctl -p /etc/sysctl.d/docker.conf
3.查看是否安装docker包
yum list docker-ce --showduplicates | sort -r
curl -o /etc/yum.repos.d/Centos-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/docker-ce.repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum clean all && yum makecache
yum list docker-ce --showduplicates | sort -r
yum install docker-ce-20.10.6 -y
mkdir /etc/docker
touch /etc/docker/daemon.json
vi /etc/docker/daemon.json
{
"registry-mirrors" : [
"https://8xpk5wnt.mirror.aliyuncs.com"
]
}
4.开启docker
[root@localhost yum.repos.d]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost yum.repos.d]# systemctl daemon-reload
[root@localhost yum.repos.d]# docker version
#查看docker是否正确启动
[root@localhost yum.repos.d]# systemctl restart docker
5.启用nginx
docker pull nginx
docker image ls
docker run -d -p 80:80 nginx
docker ps
docker ps
#查看进程
docker stop a703539004e2
#停止进程
docker start a703539004e2
6.删除容器
docker pull hello-world
docker run hello-world
docker images hello-wrold
docker rmi hello-world
docker ps
docker ps -a
#查看容器记录
docker rm 1659b5fbf53e
#删除容器记录
docker rmi hello-world
#删除容器