Docker 安装 CentOS

CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise Linux(RHEL)依照开放源代码规定发布的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定性的服务器以 CentOS 替代商业版的 Red Hat Enterprise Linux 使用。

1. 查看可用的 CentOS 版本

访问 CentOS 镜像库地址:https://dockers.xuanyuan.me/image/library/centos

2. 拉取指定版本的 CentOS 镜像

这里我们以安装 CentOS 7 为例:

docker pull centos:centos7

3. 查看本地镜像

使用以下命令查看是否已安装了 CentOS 7:

docker images

4. 运行容器

使用以下命令创建并启动 CentOS 容器:

docker run -itd --name centos-test centos:centos7

进入容器

使用以下命令进入运行中的容器:

docker exec -it centos-test /bin/bash

5. 验证安装

使用以下命令查看容器的运行信息:

docker ps