1. 安装 CentOS 7.x
略。
2. 安装 docker
详见: How to Install Docker on CentOS 6.x
3. 基础 docker 命令
获取 centos6 docker 镜像
root@docker ~ docker pull centos6
Using default tag: latest
latest: Pulling from library/centos:centos6
43db9dbdcb30: Downloading 41.14 MB/49.33 MB
43db9dbdcb30: Pull complete
2dc64e8f8d4f: Pull complete
670a583e1b50: Pull complete
183b0bfcd10e: Pull complete
Digest: sha256:c6674c44c6439673bf56536c1a15916639c47ea04c3d6296c5df938add67b54b
Status: Downloaded newer image for centso:centos6
查看当前服务器上的 docker 镜像
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos6-visionet latest aeed37612ecb 6 hours ago 1.916 GB
centos centos6 a3c09d36ab4a 2 days ago 194.6 MB
registry latest c6c14b3960bd 3 days ago 33.28 MB
查找 docker 镜像
[root@docker ~]# docker search centos:centos6
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 10 [OK]
lemonbar/centos6-ssh Installed openssh-server on centos6, defau... 7 [OK]
sergeyzh/centos6-nginx 2 [OK]
guyton/centos6 From official centos6 container with full ... 2 [OK]
paijp/centos6-apache-php-sqlite2 php5.3.3 with sqlite2 and apache on CentOS... 1 [OK]
edrans/centos6 1 [OK]
mohri1219/centos6.7-ruby2.2.2-mysql5.6 centos6.7-ruby2.2.2-mysql5.6 1 [OK]
删除 centos6 docker 镜像
[root@docker ~]# docker rmi IMAGES_NAME
[root@docker ~]# docker rmi centos:centos6
报错如下
Error response from daemon: conflict: unable to remove repository reference "centos" (must force) - container 705a30cbc002 is using its referenced image 42118e3df429
这是因为之间的运行的进程没有清楚导致该 images 正在使用中,使用一下命令查看占有的进程
[root@docker ~]# docker ps -a # 查看所有的docker进程
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
705a30cbc002 centos:centos6 "/bin/bash" 6 minutes ago Exited (0) 6 minutes ago centos6
[root@docker ~]# docker rm 705a30cbc002
705a30cbc002
[root@docker ~]# docker rmi centos:centos6
Untagged: centos:centos6
Deleted: sha256:42118e3df429f09ca581a9deb3df274601930e428e452f7e4e9f1833c56a100a
Deleted: sha256:d72d0199021776e77ac14a764a3decd156e9f6f18b37e25b867b0f1ca42fb3d9
Deleted: sha256:fb178c6cea1453d089ce033b96eba0efdb42274138e042517ea2d5ea7bb51665
Deleted: sha256:8945af30572845a904adce2aeaf73402c842d86e99e8f10688b25cb27834110b
Deleted: sha256:ea9f151abb7e06353e73172dad421235611d4f6d0560ec95db26e0dc240642c1