官方地址
https://docs.docker.com/engine/installation/linux/docker-ce/centos/
1. 卸载旧版本
较老版本的 Docker 被称为 docker 或 docker-engine。如果这些已安装,请卸载它们以及关联的依赖关系。
yum remove docker docker-common docker-selinux docker-engine
2. 安装 Docker CE
使用存储库进行安装
安装所需的软件包 yum-utils 提供 yum-config-manager 实用程序和 device-mapper-persistent-data 和 lvm2 是必需的 devicemapper 存储驱动。
yum install -y yum-utils device-mapper-persistent-data lvm2
使用下面的命令来设置稳定的存储库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
3. 安装 DOCKER CE
更新 yum 包索引。
yum makecache fast
安装 Docker CE 的最新版本或下载指定的版本。
yum install docker-ce
启动 docker
systemctl enable docker
systemctl start docker
验证是否安装成功,运行 hello-world
docker run hello-world
查看结果
[root@docker ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:97ce6fa4b6cdc0790cda65fe7290b74cfebd9fa0c9b8c38e979330d547d22ce1
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://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
[root@docker ~]#
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于