1、环境查看,系统内核要 3.10 以上的
[root@xxx docker]
3.10.0-1160.36.2.el7.x86_64
2、使用 yum 安装 gcc 相关环境,和需要的安装包
yum -y install gcc gcc-c++ yum-utils
3、卸载旧的版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
4、设置镜像仓库,使用阿里云仓库
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5、更新 yum 软件包索引
yum makecache fast
6、安装 docker 相关的 docker-ce 等等。。。
yum install docker-ce docker-ce-cli containerd.io
7、启动和停止 docker 命令
systemctl start docker
systemctl stop docker
systemctl status docker
8、使用 docker version 查看是否安装成功
docker version
[root@xxx ~]
Client: Docker Engine - Community
Version: 20.10.7
API version: 1.41
Go version: go1.13.15
Git commit: f0df350
Built: Wed Jun 2 11:58:10 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.7
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: b0f5bc3
Built: Wed Jun 2 11:56:35 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.19.0
GitCommit: de40ad0
9、设置开机启动
systemctl enable docker.service
systemctl disable docker
10、配置 docker 镜像下载加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
11、测试
docker run hello-world
12、查看一下下载的镜像
docker images
13、卸载 docker
yum remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
|