环境说明
# 查看系统内核
[root@iZwz98zi7ua638a1dxozhyZ ~]# uname -r
3.10.0-957.21.3.el7.x86_64
# 查看版本系统
[root@iZwz98zi7ua638a1dxozhyZ ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
安装步骤
官网安装参考手册:https://docs.docker.com/engine/install/centos/
(1)yum 安装 gcc 相关环境
yum -y install gcc
yum -y install gcc-c++
(2)卸载旧版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
(3)安装需要的软件包
yum install -y yum-utils
(4)设置镜像仓库
# 推荐使用国内的
yum-config-manager --add-repo http://mirrors.aliyun.com/docker- ce/linux/centos/docker-ce.repo
(5)更新 yum 软件包索引
yum makecache fast
(6)安装 Docker CE
yum install docker-ce docker-ce-cli containerd.io
(7)启动 Docker
systemctl start docker
(8)测试命令
docker version
docker run hello-world
docker images
卸载命令
systemctl stop docker
yum -y remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker