Docker 安装 CentOS


CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise Linux(RHEL) 依照开放源代码规定发布的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定性的服务器以 CentOS 替代商业版的 Red Hat Enterprise Linux 使用。
1、拉取指定版本的 CentOS 镜像,这里我们安装指定版本为例(centos7):
[root@docke ~]# docker pull centos:centos7
centos7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987
Status: Downloaded newer image for centos:centos7
2、查看本地镜像
使用以下命令来查看是否已安装了 centos7:
[root@docke ~]# docker images centos:centos7
REPOSITORY TAG IMAGE ID CREATED SIZE
centos centos7 eeb6ee3f44bd 8 hours ago 203.9 MB
3、运行容器,并且可以通过 exec 命令进入 CentOS 容器。
[root@docke ~]# docker run -itd --name centos-test --network bridge centos:centos7
5ef0d6aee0421b5b76aecb555bc49b3784cd2ab87098b043416044e1ca781d71
4、安装成功
最后我们可以通过 docker ps 命令查看容器的运行信息:
[root@docke ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5ef0d6aee042 centos:centos7 "/bin/bash" 50 seconds ago Up 49 seconds centos-test

posted @ 2021-09-16 10:34  落樰兂痕  阅读(119)  评论(0编辑  收藏  举报