目錄 搜尋
Compose About versions and upgrading (Compose) ASP.NET Core + SQL Server on Linux (Compose) CLI environment variables (Compose) Command-line completion (Compose) Compose(组成) Compose command-line reference(组合命令行参考) Control startup order (Compose) Django and PostgreSQL (Compose) Docker stacks and distributed application bundles (Compose) docker-compose build(docker-compose构建) docker-compose bundle docker-compose config docker-compose create docker-compose down docker-compose events docker-compose exec docker-compose help docker-compose images docker-compose kill docker-compose logs docker-compose pause docker-compose port docker-compose ps docker-compose pull docker-compose push docker-compose restart docker-compose rm docker-compose run docker-compose scale docker-compose start docker-compose stop docker-compose top docker-compose unpause docker-compose up Environment file (Compose) Environment variables in Compose Extend services in Compose Frequently asked questions (Compose) Getting started (Compose) Install Compose Link environment variables (deprecated) (Compose) Networking in Compose Overview of Docker Compose Overview of docker-compose CLI Quickstart: Compose and WordPress Rails and PostgreSQL (Compose) Sample apps with Compose Using Compose in production Using Compose with Swarm Engine .NET Core application (Engine) About images, containers, and storage drivers (Engine) Add nodes to the swarm (Engine) Apply custom metadata (Engine) Apply rolling updates (Engine) apt-cacher-ng Best practices for writing Dockerfiles (Engine) Binaries (Engine) Bind container ports to the host (Engine) Breaking changes (Engine) Build your own bridge (Engine) Configure container DNS (Engine) Configure container DNS in user-defined networks (Engine) CouchDB (Engine) Create a base image (Engine) Create a swarm (Engine) Customize the docker0 bridge (Engine) Debian (Engine) Default bridge network Delete the service (Engine) Deploy a service (Engine) Deploy services to a swarm (Engine) Deprecated Engine features Docker container networking (Engine) Docker overview (Engine) Docker run reference (Engine) Dockerfile reference (Engine) Dockerize an application Drain a node (Engine) Engine FAQ (Engine) Fedora (Engine) Get started (Engine) Get started with macvlan network driver (Engine) Get started with multi-host networking (Engine) How nodes work (Engine) How services work (Engine) Image management (Engine) Inspect the service (Engine) Install Docker (Engine) IPv6 with Docker (Engine) Join nodes to a swarm (Engine) Legacy container links (Engine) Lock your swarm (Engine) Manage nodes in a swarm (Engine) Manage sensitive data with Docker secrets (Engine) Manage swarm security with PKI (Engine) Manage swarm service networks (Engine) Migrate to Engine 1.10 Optional Linux post-installation steps (Engine) Overview (Engine) PostgreSQL (Engine) Raft consensus in swarm mode (Engine) Riak (Engine) Run Docker Engine in swarm mode Scale the service (Engine) SDKs (Engine) Select a storage driver (Engine) Set up for the tutorial (Engine) SSHd (Engine) Storage driver overview (Engine) Store service configuration data (Engine) Swarm administration guide (Engine) Swarm mode key concepts (Engine) Swarm mode overlay network security model (Engine) Swarm mode overview (Engine) Understand container communication (Engine) Use multi-stage builds (Engine) Use swarm mode routing mesh (Engine) Use the AUFS storage driver (Engine) Use the Btrfs storage driver (Engine) Use the Device mapper storage driver (Engine) Use the OverlayFS storage driver (Engine) Use the VFS storage driver (Engine) Use the ZFS storage driver (Engine) Engine: Admin Guide Amazon CloudWatch logs logging driver (Engine) Bind mounts (Engine) Collect Docker metrics with Prometheus (Engine) Configuring and running Docker (Engine) Configuring logging drivers (Engine) Control and configure Docker with systemd (Engine) ETW logging driver (Engine) Fluentd logging driver (Engine) Format command and log output (Engine) Google Cloud logging driver (Engine) Graylog Extended Format (GELF) logging driver (Engine) Journald logging driver (Engine) JSON File logging driver (Engine) Keep containers alive during daemon downtime (Engine) Limit a container's resources (Engine) Link via an ambassador container (Engine) Log tags for logging driver (Engine) Logentries logging driver (Engine) PowerShell DSC usage (Engine) Prune unused Docker objects (Engine) Run multiple services in a container (Engine) Runtime metrics (Engine) Splunk logging driver (Engine) Start containers automatically (Engine) Storage overview (Engine) Syslog logging driver (Engine) tmpfs mounts Troubleshoot volume problems (Engine) Use a logging driver plugin (Engine) Using Ansible (Engine) Using Chef (Engine) Using Puppet (Engine) View a container's logs (Engine) Volumes (Engine) Engine: CLI Daemon CLI reference (dockerd) (Engine) docker docker attach docker build docker checkpoint docker checkpoint create docker checkpoint ls docker checkpoint rm docker commit docker config docker config create docker config inspect docker config ls docker config rm docker container docker container attach docker container commit docker container cp docker container create docker container diff docker container exec docker container export docker container inspect docker container kill docker container logs docker container ls docker container pause docker container port docker container prune docker container rename docker container restart docker container rm docker container run docker container start docker container stats docker container stop docker container top docker container unpause docker container update docker container wait docker cp docker create docker deploy docker diff docker events docker exec docker export docker history docker image docker image build docker image history docker image import docker image inspect docker image load docker image ls docker image prune docker image pull docker image push docker image rm docker image save docker image tag docker images docker import docker info docker inspect docker kill docker load docker login docker logout docker logs docker network docker network connect docker network create docker network disconnect docker network inspect docker network ls docker network prune docker network rm docker node docker node demote docker node inspect docker node ls docker node promote docker node ps docker node rm docker node update docker pause docker plugin docker plugin create docker plugin disable docker plugin enable docker plugin inspect docker plugin install docker plugin ls docker plugin push docker plugin rm docker plugin set docker plugin upgrade docker port docker ps docker pull docker push docker rename docker restart docker rm docker rmi docker run docker save docker search docker secret docker secret create docker secret inspect docker secret ls docker secret rm docker service docker service create docker service inspect docker service logs docker service ls docker service ps docker service rm docker service scale docker service update docker stack docker stack deploy docker stack ls docker stack ps docker stack rm docker stack services docker start docker stats docker stop docker swarm docker swarm ca docker swarm init docker swarm join docker swarm join-token docker swarm leave docker swarm unlock docker swarm unlock-key docker swarm update docker system docker system df docker system events docker system info docker system prune docker tag docker top docker unpause docker update docker version docker volume docker volume create docker volume inspect docker volume ls docker volume prune docker volume rm docker wait Use the Docker command line (Engine) Engine: Extend Access authorization plugin (Engine) Docker log driver plugins Docker network driver plugins (Engine) Extending Engine with plugins Managed plugin system (Engine) Plugin configuration (Engine) Plugins API (Engine) Volume plugins (Engine) Engine: Security AppArmor security profiles for Docker (Engine) Automation with content trust (Engine) Content trust in Docker (Engine) Delegations for content trust (Engine) Deploying Notary (Engine) Docker security (Engine) Docker security non-events (Engine) Isolate containers with a user namespace (Engine) Manage keys for content trust (Engine) Play in a content trust sandbox (Engine) Protect the Docker daemon socket (Engine) Seccomp security profiles for Docker (Engine) Secure Engine Use trusted images Using certificates for repository client verification (Engine) Engine: Tutorials Engine tutorials Network containers (Engine) Get Started Part 1: Orientation Part 2: Containers Part 3: Services Part 4: Swarms Part 5: Stacks Part 6: Deploy your app Machine Amazon Web Services (Machine) Digital Ocean (Machine) docker-machine active docker-machine config docker-machine create docker-machine env docker-machine help docker-machine inspect docker-machine ip docker-machine kill docker-machine ls docker-machine provision docker-machine regenerate-certs docker-machine restart docker-machine rm docker-machine scp docker-machine ssh docker-machine start docker-machine status docker-machine stop docker-machine upgrade docker-machine url Driver options and operating system defaults (Machine) Drivers overview (Machine) Exoscale (Machine) Generic (Machine) Get started with a local VM (Machine) Google Compute Engine (Machine) IBM Softlayer (Machine) Install Machine Machine Machine CLI overview Machine command-line completion Machine concepts and help Machine overview Microsoft Azure (Machine) Microsoft Hyper-V (Machine) Migrate from Boot2Docker to Machine OpenStack (Machine) Oracle VirtualBox (Machine) Provision AWS EC2 instances (Machine) Provision Digital Ocean Droplets (Machine) Provision hosts in the cloud (Machine) Rackspace (Machine) VMware Fusion (Machine) VMware vCloud Air (Machine) VMware vSphere (Machine) Notary Client configuration (Notary) Common Server and signer configurations (Notary) Getting started with Notary Notary changelog Notary configuration files Running a Notary service Server configuration (Notary) Signer configuration (Notary) Understand the service architecture (Notary) Use the Notary client
文字

描述

列表图像

用法

docker images [OPTIONS] [REPOSITORY[:TAG]]

备选方案

名字,简写

默认

描述

--all, -a

false

显示所有图像(默认隐藏中间图像)

--digests

false

显示摘要

--filter, -f


根据提供的条件过滤输出

--format


使用Go模板打印出漂亮的图像

--no-trunc

false

不要截断输出

--quiet, -q

false

只显示数字ID

父命令

Command

Description

docker

The base command for the Docker CLI.

扩展描述

默认docker images将显示所有顶级图像,它们的存储库和标签,以及它们的大小。

Docker 映像具有中间层,docker build通过允许缓存每个步骤来提高可重用性,减少磁盘使用并加快速度。这些中间层默认不显示。

SIZE是图像及其所有父图像占用的累积空间。这也是您docker save在映像中创建的 Tar 文件内容所使用的磁盘空间。

如果图像具有多个存储库名称或标签,则图像将被多次列出。这张单张图片(通过匹配识别IMAGE IDSIZE只用了一次。

实例

列出最近创建的图像

$ docker images

REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE<none>                    <none>              77af4d6b9913        19 hours ago        1.089 GB
committ                   latest              b6fa739cedf5        19 hours ago        1.089 GB<none>                    <none>              78a85c484f71        19 hours ago        1.089 GB
docker                    latest              30557a29d5ab        20 hours ago        1.089 GB<none>                    <none>              5ed6274db6ce        24 hours ago        1.089 GB
postgres                  9                   746b819f315e        4 days ago          213.4 MB
postgres                  9.3                 746b819f315e        4 days ago          213.4 MB
postgres                  9.3.5               746b819f315e        4 days ago          213.4 MB
postgres                  latest              746b819f315e        4 days ago          213.4 MB

按名称和标签列出图像

docker images命令采用可选[REPOSITORY[:TAG]]参数,将列表限制为与参数匹配的图像。如果您指定REPOSITORY但不是TAG,则该docker images命令会列出给定存储库中的所有图像。

例如,要列出“java”存储库中的所有图像,请运行以下命令:

$ docker images java

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
java                8                   308e519aac60        6 days ago          824.5 MB
java                7                   493d82594c15        3 months ago        656.3 MB
java                latest              2711b1d6f3aa        5 months ago        603.9 MB

[REPOSITORY[:TAG]]值必须是“完全匹配”。这意味着,例如,docker images jav与图像不匹配java

如果提供REPOSITORYTAG,仅匹配库和标签图像中列出。要在标签为“8”的“java”存储库中查找所有本地图像,可以使用:

$ docker images java:8REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
java                8                   308e519aac60        6 days ago          824.5 MB

如果没有匹配REPOSITORY[:TAG],则列表为空。

$ docker images java:0REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

列出完整的图像 ID

$ docker images --no-trunc

REPOSITORY                    TAG                 IMAGE ID                                                                  CREATED             SIZE<none>                        <none>              sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182   19 hours ago        1.089 GB
committest                    latest              sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f   19 hours ago        1.089 GB<none>                        <none>              sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921   19 hours ago        1.089 GB
docker                        latest              sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4   20 hours ago        1.089 GB<none>                        <none>              sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5   20 hours ago        1.089 GB<none>                        <none>              sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b   22 hours ago        1.082 GB<none>                        <none>              sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a   23 hours ago        1.089 GB
tryout                        latest              sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074   23 hours ago        131.5 MB<none>                        <none>              sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df   24 hours ago        1.089 GB

列表图像摘要

使用 v2 或更高版本格式的图像具有称为digest的内容可寻址标识符。只要用于生成图像的输入不变,摘要值就可以预测。要列出图片摘要值,请使用以下--digests标志:

$ docker images --digests
REPOSITORY                         TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
localhost:5000/test/busybox        <none>              sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   4986bf8c1536        9 weeks ago         2.43 MB

当推或拉到2.0注册表时,pushpull命令输出包含图像摘要。您可以pull使用摘要值。您也可以通过引用消化createrunrmi命令,还有FROM在 Dockerfile 图像参考。

过滤

过滤标志(-f--filter)格式为“key = value”。如果有多个过滤器,则传递多个标志(例如--filter "foo=bar" --filter "bif=baz"

目前支持的过滤器是:

  • dangling(布尔 - true 或 false )

  • 标签(label=<key>label=<key>=<value>

  • before(<image-name>[:<tag>]<image id><image@digest>) -过滤图像创建之前给定 id 或引用

  • 因为(<image-name>[:<tag>]<image id><image@digest>) -给定 id 或引用创建的过滤器的图像

  • 参考(图像参考的图案) - 过滤参考与指定图案匹配的图像

显示未加标签的图像( dangling

$ docker images --filter "dangling=true"REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE<none>              <none>              8abc22fbb042        4 weeks ago         0 B<none>              <none>              48e5f45168b9        4 weeks ago         2.489 MB<none>              <none>              bf747efa0e2f        4 weeks ago         0 B<none>              <none>              980fe10e5736        12 weeks ago        101.4 MB<none>              <none>              dea752e4e117        12 weeks ago        101.4 MB<none>              <none>              511136ea3c5a        8 months ago        0 B

这将显示未标记的图像,即图像树的叶子(不是中间层)。这些图像在图像的新版本repo:tag将图像标识从图像标识中移开时保留为<none>:<none>或不标记。如果在容器正在使用时尝试删除图像,则会发出警告。通过拥有这个标志,它可以批量清理。

你可以结合使用这个docker rmi ...

$ docker rmi $(docker images -f "dangling=true" -q)8abc22fbb042
48e5f45168b9
bf747efa0e2f
980fe10e5736
dea752e4e117
511136ea3c5a

::Docker 发出警告,如果存在使用这些无标记图像的容器。

用给定的标签显示图像

label过滤器匹配基础上的存在的图像label单独或label和值。

以下过滤器将图像与com.example.version标签进行匹配,而不管其值如何。

$ docker images --filter "label=com.example.version"REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
match-me-1          latest              eeae25ada2aa        About a minute ago   188.3 MB
match-me-2          latest              dea752e4e117        About a minute ago   188.3 MB

下面的筛选器将图像与com.example.version标签上带有1.0价值。

$ docker images --filter "label=com.example.version=1.0"REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
match-me            latest              511136ea3c5a        About a minute ago   188.3 MB

在本例中,使用0.1值时,它返回一个空集,因为没有找到匹配项。

$ docker images --filter "label=com.example.version=0.1"REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE

按时间过滤图像

before过滤器仅显示在具有给定 ID 或引用的图像之前创建的图像。例如,拥有这些图像:

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
image1              latest              eeae25ada2aa        4 minutes ago        188.3 MB
image2              latest              dea752e4e117        9 minutes ago        188.3 MB
image3              latest              511136ea3c5a        25 minutes ago       188.3 MB

过滤用before会:

$ docker images --filter "before=image1"REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
image2              latest              dea752e4e117        9 minutes ago        188.3 MB
image3              latest              511136ea3c5a        25 minutes ago       188.3 MB

过滤用since会:

$ docker images --filter "since=image3"REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
image1              latest              eeae25ada2aa        4 minutes ago        188.3 MB
image2              latest              dea752e4e117        9 minutes ago        188.3 MB

参考滤波图像

reference过滤器仅显示引用与指定模式匹配的图像。

$ docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             latest              e02e811dd08f        5 weeks ago         1.09 MB
busybox             uclibc              e02e811dd08f        5 weeks ago         1.09 MB
busybox             musl                733eb3059dce        5 weeks ago         1.21 MB
busybox             glibc               21c16b6787c6        5 weeks ago         4.19 MB

过滤用reference会:

$ docker images --filter=reference='busy*:*libc'REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             uclibc              e02e811dd08f        5 weeks ago         1.09 MB
busybox             glibc               21c16b6787c6        5 weeks ago         4.19 MB

格式化输出

格式化选项(--format)将使用 Go 模板打印容器输出。

下面列出了 Go 模板的有效占位符:

Placeholder

Description

.ID

Image ID

.Repository

Image repository

.Tag

Image tag

.Digest

Image digest

.CreatedSince

Elapsed time since the image was created

.CreatedAt

Time when the image was created

.Size

Image disk size

当使用--format选项时,image命令将完全按照模板声明输出数据,或者在使用该table指令时也会包含列标题。

以下示例使用不带标题的模板,并输出由冒号分隔的所有图像IDRepository条目:

$ docker images --format "{{.ID}}: {{.Repository}}"77af4d6b9913: <none>b6fa739cedf5: committ
78a85c484f71: <none>30557a29d5ab: docker
5ed6274db6ce: <none>746b819f315e: postgres
746b819f315e: postgres
746b819f315e: postgres
746b819f315e: postgres

要以表格格式列出存储库和标签的所有图像,可以使用:

$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"IMAGE ID            REPOSITORY                TAG
77af4d6b9913        <none>                    <none>b6fa739cedf5        committ                   latest
78a85c484f71        <none>                    <none>30557a29d5ab        docker                    latest
5ed6274db6ce        <none>                    <none>746b819f315e        postgres                  9746b819f315e        postgres                  9.3746b819f315e        postgres                  9.3.5746b819f315e        postgres                  latest
上一篇: 下一篇: