安裝docker(社區(qū)版)的命令如下:
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權(quán)限摘刑。
如果不理解,可以參看下面的詳情刻坊。
一枷恕、下載docker源
在CentOS 8 和RHEL 8中已經(jīng)移除了docker的源,所以需要下載:
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
注:dnf是新一代的rpm軟件包管理器谭胚,替代了yum徐块。
二、使用dnf命令安裝Docker
配置好了docker源之后灾而,就可以通過下面的命令查看可以安裝的docker-ce(docker社區(qū)版)的版本:
dnf list docker-ce
安裝docker:
dnf install docker-ce --nobest -y
啟動docker胡控,并設(shè)置開機自啟:
systemctl start docker
systemctl enable docker
查看已安裝的docker版本
docker --version
三、檢測docker是否安裝成功
執(zhí)行命令:
docker run hello-world
出現(xiàn)如下提示說明安裝成功:
Hello from Docker!
This message shows that your installation appears to be working correctly.
docker run hello-world命令完整打印信息:
[root@chushiyan ~]# 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/
注:參考博客