拉取centos7镜像
[root@iZ2ze13w9axywmzuqgmegoZ ~]# docker pull centos:centos7
centos7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
Status: Downloaded newer image for centos:centos7
docker.io/library/centos:centos7
查看镜像
[root@iZ2ze13w9axywmzuqgmegoZ ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos centos7 8652b9f0cb4c 3 months ago 204MB
构建容器
[root@iZ2ze13w9axywmzuqgmegoZ ~]# docker run -itd --name centos7 centos:centos7
15296c6e5278b8aa0cf8bd0d0413156f40d4e818ba1938e7edc1f1f76873b5a3
options | mean |
---|---|
i | 以交互模式运行容器,通常与 -t 同时使用; |
t | 为容器重新分配一个伪输入终端,通常与 -i 同时使用; |
d | 后台运行容器,并返回容器ID; |
查看运行的容器
[root@iZ2ze13w9axywmzuqgmegoZ ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
15296c6e5278 centos:centos7 "/bin/bash" About a minute ago Up About a minute centos7
进入容器内的系统
[root@iZ2ze13w9axywmzuqgmegoZ ~]# docker exec -it centos7 bash
[root@15296c6e5278 /]#