在CentOS8、红帽8系统中安装Docker:只需4条命令

安装docker(社区版)的命令如下:

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install docker-ce --nobest -y
systemctl start docker
systemctl enable docker

注意:需要root权限。

如果不理解,可以参看下面的详情。

一、下载docker源

在CentOS 8 和RHEL 8中已经移除了docker的源,所以需要下载:

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

注:dnf是新一代的rpm软件包管理器,替代了yum。

二、使用dnf命令安装Docker

配置好了docker源之后,就可以通过下面的命令查看可以安装的docker-ce(docker社区版)的版本:

dnf list docker-ce

安装docker:

dnf install docker-ce --nobest -y

启动docker,并设置开机自启:

systemctl start docker
systemctl enable docker

查看已安装的docker版本

docker --version

三、检测docker是否安装成功

执行命令:

docker run hello-world

出现如下提示说明安装成功:

Hello from Docker!
This message shows that your installation appears to be working correctly.

docker run hello-world命令完整打印信息:

[root@localhost ~]# docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

注:参考博客

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值