# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES efc9bda4a2ff csphere/test:0.1 "/usr/local/bin/run 4 minutes ago Up 17 seconds con03 99aa6ee25adc busybox:latest "/bin/sh" 14 minutes ago Exited (0) 12 minutes ago con02 831c93de9b9f busybox:latest "/bin/sh" 2 hours ago Up 27 minutes con01 # docker rm con02 #容器停止的状态 # docker rm -f con03 #容器开启的状态
镜像操作
1. 从 docker hub 官方镜像仓库拉取镜像
# docker pull busybox:latest atest: Pulling from busybox cf2616975b4a: Pull complete 6ce2e90b0bc7: Pull complete 8c2e06607696: Already exists busybox:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security. Digest: sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d Status: Downloaded newer image for busybox:latest
2. 从本地上传镜像到镜像仓库
docker push 192.168.1.2/csphere/nginx:1.7
3. 查找镜像仓库的某个镜像
# docker search centos/nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED johnnyzheng/centos-nginx-php-wordpress 1 [OK] sergeyzh/centos6-nginx 1 [OK] hzhang/centos-nginx 1 [OK]
4. 查看本地镜像列表
# docker images TAG IMAGE ID CREATED VIRTUAL SIZE docker.io/csphere/csphere 0.10.3 604c03bf0c9e 3 days ago 62.72 MB docker.io/csphere/csphere latest 604c03bf0c9e 3 days ago 62.72 MB csphere/csphere 0.10.3 604c03bf0c9e 3 days ago 62.72 MB registry 2.0 2971b6ce766c 7 days ago 548.1 MB busybox latest 8c2e06607696 3 weeks ago 2.43 MB
5. 删除镜像
docker rmi busybox:latest #没有容器使用此镜像创建,如果有容器在使用此镜像会报错:Error response from daemon: Conflict, cannot delete 8c2e06607696 because the running container 831c93de9b9f is using it, stop it and use -f to force FATA[0000] Error: failed to remove one or more images docker rmi -f busybox:latest #容器使用此镜像创建,此容器状态为Exited
6. 查看构建镜像所用过的命令
# docker history busybox:latest IMAGE CREATED CREATED BY SIZE 8c2e06607696 3 weeks ago /bin/sh -c #(nop) CMD ["/bin/sh"] 0 B 6ce2e90b0bc7 3 weeks ago /bin/sh -c #(nop) ADD file:8cf517d90fe79547c4 2.43 MB cf2616975b4a 3 weeks ago /bin/sh -c #(nop) MAINTAINER Jérôme Petazzo 0 B