- images 显示镜像列表
root@ubuntu:/home/yj# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image latest 156761cbda42 4 days ago 200MB
httpd latest 0240c8f5816c 9 days ago 132MB
centos latest 75835a67d134 2 weeks ago 200MB
root@ubuntu:/home/yj# docker images my-image
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image latest 156761cbda42 4 days ago 200MB
root@ubuntu:/home/yj#
- history 显示镜像构建历史
root@ubuntu:/home/yj# docker history my-image
IMAGE CREATED CREATED BY SIZE COMMENT
156761cbda42 4 days ago /bin/sh -c #(nop) ENV WELCOME=you are in mu… 0B
58c8dc2c1373 4 days ago /bin/sh -c #(nop) ADD file:1dd32835d0dddd036… 0B
8e2dc00832b6 4 days ago /bin/sh -c #(nop) COPY file:c47f7dda7d4863fc… 0B
f01a0290b924 4 days ago /bin/sh -c touch tmpfile1 0B
01472d2d5f9f 4 days ago /bin/sh -c #(nop) WORKDIR /testdir 0B
e66224d7b144 4 days ago /bin/sh -c #(nop) MAINTAINER yangjin@qq.com 0B
75835a67d134 2 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 2 weeks ago /bin/sh -c #(nop) LABEL org.label-schema.sc… 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ADD file:fbe9badfd2790f074… 200MB
- commit 从容器创建新镜像
root@ubuntu:/home/yj# docker commit 0c077430c575 my-image2:latest
sha256:3ec340b57cca0fbaeff12f082ad33153d5529ae432cb53a2336dba3311b1731b
root@ubuntu:/home/yj# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image2 latest 3ec340b57cca 18 seconds ago 132MB
- build 从Dockerfile 构建镜像
容器学习 之 扩展镜像(五) 这里有提到怎么用Dockerfile构建镜像,这也是比较推荐的方式。
- tag 给镜像打 tag
root@ubuntu:/home/yj# docker tag my-image2 my-image2:Jim
root@ubuntu:/home/yj# docker images my-image2
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image2 Jim 3ec340b57cca 5 minutes ago 132MB
my-image2 latest 3ec340b57cca 5 minutes ago 132MB
- rmi 删除 Docker host 中的镜像
root@ubuntu:/home/yj# docker images my-image2
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image2 Jim 3ec340b57cca 7 minutes ago 132MB
my-image2 Ketty 3ec340b57cca 7 minutes ago 132MB
my-image2 latest 3ec340b57cca 7 minutes ago 132MB
#删除指定版本号的镜像
root@ubuntu:/home/yj# docker rmi my-image2:Jim
Untagged: my-image2:Jim
root@ubuntu:/home/yj# docker images my-image2
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image2 Ketty 3ec340b57cca 8 minutes ago 132MB
my-image2 latest 3ec340b57cca 8 minutes ago 132MB
#默认删除最新版本的镜像
root@ubuntu:/home/yj# docker rmi my-image2
Untagged: my-image2:latest
root@ubuntu:/home/yj# docker images my-image2
REPOSITORY TAG IMAGE ID CREATED SIZE
my-image2 Ketty 3ec340b57cca 8 minutes ago 132MB
- search 搜索Docker Hub中的镜像
root@ubuntu:/home/yj# docker search httpd
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 2098 [OK]
hypriot/rpi-busybox-httpd Raspberry Pi compatible Docker Image with a … 44
centos/httpd 21 [OK]
centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or bui… 18
armhf/httpd The Apache HTTP Server Project 8
- pull 从registry下载镜像
- push 将镜像上传到registry
下章我们将介绍如何建立本地仓库和上传到公有仓库。