目录搜索
ComposeAbout 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 bundledocker-compose configdocker-compose createdocker-compose downdocker-compose eventsdocker-compose execdocker-compose helpdocker-compose imagesdocker-compose killdocker-compose logsdocker-compose pausedocker-compose portdocker-compose psdocker-compose pulldocker-compose pushdocker-compose restartdocker-compose rmdocker-compose rundocker-compose scaledocker-compose startdocker-compose stopdocker-compose topdocker-compose unpausedocker-compose upEnvironment file (Compose)Environment variables in ComposeExtend services in ComposeFrequently asked questions (Compose)Getting started (Compose)Install ComposeLink environment variables (deprecated) (Compose)Networking in ComposeOverview of Docker ComposeOverview of docker-compose CLIQuickstart: Compose and WordPressRails and PostgreSQL (Compose)Sample apps with ComposeUsing Compose in productionUsing Compose with SwarmEngine.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-ngBest 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 networkDelete the service (Engine)Deploy a service (Engine)Deploy services to a swarm (Engine)Deprecated Engine featuresDocker container networking (Engine)Docker overview (Engine)Docker run reference (Engine)Dockerfile reference (Engine)Dockerize an applicationDrain a node (Engine)EngineFAQ (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.10Optional Linux post-installation steps (Engine)Overview (Engine)PostgreSQL (Engine)Raft consensus in swarm mode (Engine)Riak (Engine)Run Docker Engine in swarm modeScale 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 GuideAmazon 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 mountsTroubleshoot 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: CLIDaemon CLI reference (dockerd) (Engine)dockerdocker attachdocker builddocker checkpointdocker checkpoint createdocker checkpoint lsdocker checkpoint rmdocker commitdocker configdocker config createdocker config inspectdocker config lsdocker config rmdocker containerdocker container attachdocker container commitdocker container cpdocker container createdocker container diffdocker container execdocker container exportdocker container inspectdocker container killdocker container logsdocker container lsdocker container pausedocker container portdocker container prunedocker container renamedocker container restartdocker container rmdocker container rundocker container startdocker container statsdocker container stopdocker container topdocker container unpausedocker container updatedocker container waitdocker cpdocker createdocker deploydocker diffdocker eventsdocker execdocker exportdocker historydocker imagedocker image builddocker image historydocker image importdocker image inspectdocker image loaddocker image lsdocker image prunedocker image pulldocker image pushdocker image rmdocker image savedocker image tagdocker imagesdocker importdocker infodocker inspectdocker killdocker loaddocker logindocker logoutdocker logsdocker networkdocker network connectdocker network createdocker network disconnectdocker network inspectdocker network lsdocker network prunedocker network rmdocker nodedocker node demotedocker node inspectdocker node lsdocker node promotedocker node psdocker node rmdocker node updatedocker pausedocker plugindocker plugin createdocker plugin disabledocker plugin enabledocker plugin inspectdocker plugin installdocker plugin lsdocker plugin pushdocker plugin rmdocker plugin setdocker plugin upgradedocker portdocker psdocker pulldocker pushdocker renamedocker restartdocker rmdocker rmidocker rundocker savedocker searchdocker secretdocker secret createdocker secret inspectdocker secret lsdocker secret rmdocker servicedocker service createdocker service inspectdocker service logsdocker service lsdocker service psdocker service rmdocker service scaledocker service updatedocker stackdocker stack deploydocker stack lsdocker stack psdocker stack rmdocker stack servicesdocker startdocker statsdocker stopdocker swarmdocker swarm cadocker swarm initdocker swarm joindocker swarm join-tokendocker swarm leavedocker swarm unlockdocker swarm unlock-keydocker swarm updatedocker systemdocker system dfdocker system eventsdocker system infodocker system prunedocker tagdocker topdocker unpausedocker updatedocker versiondocker volumedocker volume createdocker volume inspectdocker volume lsdocker volume prunedocker volume rmdocker waitUse the Docker command line (Engine)Engine: ExtendAccess authorization plugin (Engine)Docker log driver pluginsDocker network driver plugins (Engine)Extending Engine with pluginsManaged plugin system (Engine)Plugin configuration (Engine)Plugins API (Engine)Volume plugins (Engine)Engine: SecurityAppArmor 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 EngineUse trusted imagesUsing certificates for repository client verification (Engine)Engine: TutorialsEngine tutorialsNetwork containers (Engine)Get StartedPart 1: OrientationPart 2: ContainersPart 3: ServicesPart 4: SwarmsPart 5: StacksPart 6: Deploy your appMachineAmazon Web Services (Machine)Digital Ocean (Machine)docker-machine activedocker-machine configdocker-machine createdocker-machine envdocker-machine helpdocker-machine inspectdocker-machine ipdocker-machine killdocker-machine lsdocker-machine provisiondocker-machine regenerate-certsdocker-machine restartdocker-machine rmdocker-machine scpdocker-machine sshdocker-machine startdocker-machine statusdocker-machine stopdocker-machine upgradedocker-machine urlDriver 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 MachineMachineMachine CLI overviewMachine command-line completionMachine concepts and helpMachine overviewMicrosoft Azure (Machine)Microsoft Hyper-V (Machine)Migrate from Boot2Docker to MachineOpenStack (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)NotaryClient configuration (Notary)Common Server and signer configurations (Notary)Getting started with NotaryNotary changelogNotary configuration filesRunning a Notary serviceServer 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
上一篇:下一篇: