Docker 安裝 CentOS

CentOS(Community Enterprise Operating System)是 Linux 發行版之一,它是來自於 Red Hat Enterprise Linux(RHEL) 依照開放源代碼規定發佈的源代碼所編譯而成。由於出自同樣的源代碼,因此有些要求高度穩定性的伺服器以 CentOS 替代商業版的 Red Hat Enterprise Linux 使用。

1、查看可用的 CentOS 版本

訪問 CentOS 鏡像庫地址:https://hub.docker.com/_/centos?tab=tags&page=1

可以通過 Sort by 查看其他版本的 CentOS 。默認是最新版本 centos:latest 。

你也可以在下拉列表中找到其他你想要的版本:

2、拉取指定版本的 CentOS 鏡像,這裏我們安裝指定版本為例(centos7):

$ docker pull centos:centos7

3、查看本地鏡像

使用以下命令來查看是否已安裝了 centos7:

$ docker images

4、運行容器,並且可以通過 exec 命令進入 CentOS 容器。

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

5、安裝成功

最後我們可以通過 docker ps 命令查看容器的運行資訊: