centos7 下 docker-ce 搭建

本贴最后更新于 2025 天前,其中的信息可能已经水流花落

官方地址

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 ~]# 

  • CentOS

    CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise Linux 依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定的服务器以 CentOS 替代商业版的 Red Hat Enterprise Linux 使用。两者的不同在于 CentOS 并不包含封闭源代码软件。

    238 引用 • 224 回帖
  • Docker

    Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的操作系统上。容器完全使用沙箱机制,几乎没有性能开销,可以很容易地在机器和数据中心中运行。

    475 引用 • 899 回帖 • 1 关注

相关帖子

欢迎来到这里!

我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。

注册 关于
请输入回帖内容 ...