docker_practice/image/list.md

151 lines
8.8 KiB
Go
Raw Normal View History

#
使 `docker image ls`
```bash
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 5f515359c7f8 5 days ago 183 MB
nginx latest 05a60462f8ba 5 days ago 181 MB
mongo 3.2 fe9198c04d62 5 days ago 342 MB
<none> <none> 00285df0df87 5 days ago 342 MB
ubuntu 18.04 329ed837d508 3 days ago 63.3MB
ubuntu bionic 329ed837d508 3 days ago 63.3MB
```
2017-12-01 17:33:05 +08:00
`仓库名``标签``镜像 ID``创建时间` `所占用的空间`
** ID** **** `ubuntu:18.04` `ubuntu:bionic` ID
##
Docker Hub `ubuntu:18.04` `63.3MB` [Docker Hub](https://hub.docker.com/layers/ubuntu/library/ubuntu/bionic/images/sha256-32776cc92b5810ce72e77aca1d949de1f348e1d281d3f00ebcc22a3adcdc9f42?context=explore) 显示的却是 `25.47 MB`。这是因为 Docker Hub 中显示的体积是压缩后的体积。在镜像下载和上传过程中镜像是保持着压缩状态的,因此 Docker Hub 所显示的大小是网络传输中更关心的流量大小。而 `docker image ls` 显示的是镜像下载到本地后,展开的大小,准确说,是展开后的各层所占空间的总和,因为镜像到本地后,查看空间的时候,更关心的是本地磁盘空间占用的大小。
`docker image ls` Docker 使 Docker 使 Union FS
`docker system df` 便
2017-11-13 18:19:35 +08:00
```bash
$ docker system df
2017-11-22 20:28:10 +08:00
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 24 0 1.992GB 1.992GB (100%)
Containers 1 0 62.82MB 62.82MB (100%)
Local Volumes 9 0 652.2MB 652.2MB (100%)
Build Cache 0B 0B
2017-11-13 18:19:35 +08:00
```
##
`<none>`
```bash
<none> <none> 00285df0df87 5 days ago 342 MB
```
`mongo:3.2` `docker pull mongo:3.2` `mongo:3.2` `<none>` `docker pull` `docker build` `<none>` **(dangling image)**
```bash
$ docker image ls -f dangling=true
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 00285df0df87 5 days ago 342 MB
```
```bash
$ docker image prune
```
##
Docker ****使 `docker image ls` `-a`
```bash
$ docker image ls -a
```
##
`docker image ls` `docker image ls`
```bash
$ docker image ls ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 329ed837d508 3 days ago 63.3MB
ubuntu bionic 329ed837d508 3 days ago 63.3MB
```
```bash
$ docker image ls ubuntu:18.04
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 329ed837d508 3 days ago 63.3MB
```
`docker image ls` `--filter` `-f`使 `mongo:3.2`
```bash
$ docker image ls -f since=mongo:3.2
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 5f515359c7f8 5 days ago 183 MB
nginx latest 05a60462f8ba 5 days ago 181 MB
```
`since` `before`
`LABEL` `LABEL`
```bash
$ docker image ls -f label=com.example.version=0.1
...
```
##
`docker image ls` `docker image ls` ID `docker image rm` `-q`
```bash
$ docker image ls -q
5f515359c7f8
05a60462f8ba
fe9198c04d62
00285df0df87
329ed837d508
329ed837d508
```
`--filter` `-q` ID `docker` Docker 使
便 [Go ](https://gohugo.io/templates/introduction/)。
ID
```bash
$ docker image ls --format "{{.ID}}: {{.Repository}}"
5f515359c7f8: redis
05a60462f8ba: nginx
fe9198c04d62: mongo
00285df0df87: <none>
329ed837d508: ubuntu
329ed837d508: ubuntu
```
```bash
$ docker image ls --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
IMAGE ID REPOSITORY TAG
5f515359c7f8 redis latest
05a60462f8ba nginx latest
fe9198c04d62 mongo 3.2
00285df0df87 <none> <none>
329ed837d508 ubuntu 18.04
329ed837d508 ubuntu bionic
```