CentOS7 安装 Docker

206 阅读1分钟

查看系统版本

使用 cat /etc/os-release 命令查看Linux 发行版名称和版本号

[root@ip ~]# 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"

卸载老版本

 sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

设置仓库地址

安装 yum-utils

sudo yum install -y yum-utils

设置 docker 稳定版仓库地址

sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

安装 docker 引擎

安装最新版本引擎和容器

sudo yum install docker-ce docker-ce-cli containerd.io

按照提示一步步安装就OK了, 查看版本如下

[root@ip ~]# docker -v
Docker version 20.10.6, build 370c289

启动 docker

systemctl start docker

运行 hello-world 镜像

docker run hello-world

相关链接

www.docker.com/

docs.docker.com/engine/inst…

www.jianshu.com/nb/29874900

如果喜欢,点个赞再走呗 ^-^