CentOS7使用yum方式安装Docker(根据官方文档安装)

Docker(yum安装)

说明:

以官方文档和最新的版本为例
docker官网:https://docs.docker.com/engine/install/centos/

1.检测当前系统版本

官方文档:
OS requirements
To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.
The centos-extras repository must be enabled. This repository is enabled by default, but if you have disabled it, you need to re-enable it.
要安装 Docker Engine,你需要一个 CentOS 7或8的维护版本。
必须启用 centos-extras 存储库。此存储库默认是启用的,但是如果您已经禁用了它,则需要重新启用它。

[root@localhost bin]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

2.卸载旧版本:Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.
旧版本的 Docker 被称为 Docker 或 Docker-engine。如果已经安装了它们,请卸载它们以及相关的依赖项。

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

在这里插入图片描述

3.安装准备环境

yum -y install gcc-c++
在这里插入图片描述

4.Installation methods 安装方法

官方文档:
Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.
大多数用户建立了 Docker 的存储库并从中安装,以便于安装和升级任务。这是推荐的方法。

(1)Set up the repository 设置存储库

Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository.
安装 yum-utils 包(它提供 yum-config-manager 实用工具)并设置稳定存储库。

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

在这里插入图片描述

(2)Install Docker Engine 安装 Docker 引擎

Install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:
安装最新版本的 Docker Engine 和 containerd,或者进入下一步安装一个特定版本:

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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

(3)Start Docker 启动 Docker

sudo systemctl start docker

在这里插入图片描述

(4)测试是否安装成功

Verify that Docker Engine is installed correctly by running the hello-world image.
通过运行 hello-world 映像来验证 Docker Engine 安装是否正确。

 sudo docker run hello-world

在这里插入图片描述
在这里插入图片描述

This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.
此命令下载测试映像并在容器中运行它。当容器运行时,它打印一条消息并退出。

This installs and runs Docker Engine. Use sudo to run Docker commands. Continue to Linux postinstall to allow non-privileged users to run Docker commands and for other optional configuration steps.
这将安装并运行 Docker 引擎。使用 sudo 运行 Docker 命令。继续安装 Linux 后,允许非特权用户运行 Docker 命令和其他可选配置步骤。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐州蔡徐坤

又要到饭了兄弟们

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值