Docker(二):鏡像命令

命令

## 查看本地鏡像
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              4ab4c602aa5e        4 weeks ago         1.84kB
REPOSITORY:表示鏡像的倉庫源
TAG:鏡像的標籤
IMAGE ID :鏡像id
CREATED:鏡像建立時間
SIZE:鏡像大小
## 查看本地全部鏡像(含中間映像層)
# docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              4ab4c602aa5e        4 weeks ago         1.84kB

## 只顯示鏡像id
# docker images -q
4ab4c602aa5e

## 顯示鏡像的摘要信息
# docker images --digests
REPOSITORY          TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
hello-world         latest              sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788   4ab4c602aa5e        4 weeks ago         1.84kB

## 顯示完整的鏡像信息
# docker images --digests --no-trunc
REPOSITORY          TAG                 DIGEST                                                                    IMAGE ID                                                                  CREATED             SIZE
hello-world         latest              sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788   sha256:4ab4c602aa5eed5528a6620ff18a1dc4faef0e1ab3a5eddeddb410714478c67f   4 weeks ago         1.84kB
## 查找鏡像
# docker search tomcat
NAME                                  DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
tomcat                                Apache Tomcat is an open source implementati…   2072                [OK]                
tomee                                 Apache TomEE is an all-Apache Java EE certif…   56                  [OK]                
dordoka/tomcat                        Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base…   49                                      [OK]
davidcaste/alpine-tomcat              Apache Tomcat 7/8 using Oracle Java 7/8 with…   30                                      [OK]
bitnami/tomcat                        Bitnami Tomcat Docker Image                     25                                      [OK]
consol/tomcat-7.0                     Tomcat 7.0.57, 8080, "admin/admin"              16                                      [OK]
cloudesire/tomcat                     Tomcat server, 6/7/8                            15                                      [OK]
tutum/tomcat                          Base docker image to run a Tomcat applicatio…   11                                      
meirwa/spring-boot-tomcat-mysql-app   a sample spring-boot app using tomcat and My…   10                                      [OK]
aallam/tomcat-mysql                   Debian, Oracle JDK, Tomcat & MySQL              8                                       [OK]
jeanblanchard/tomcat                  Minimal Docker image with Apache Tomcat         8                                       
maluuba/tomcat7-java8                 Tomcat7 with java8.                             3                                       
rightctrl/tomcat                      CentOS , Oracle Java, tomcat application ssl…   3                                       [OK]
arm64v8/tomcat                        Apache Tomcat is an open source implementati…   2                                       
amd64/tomcat                          Apache Tomcat is an open source implementati…   2                                       
99taxis/tomcat7                       Tomcat7                                         1                                       [OK]
primetoninc/tomcat                    Apache tomcat 8.5, 8.0, 7.0                     1                                       [OK]
jelastic/tomcat                       An image of the Tomcat Java application serv…   1                                       
fabric8/tomcat-8                      Fabric8 Tomcat 8 Image                          1                                       [OK]
camptocamp/tomcat-logback             Docker image for tomcat with logback integra…   1                                       [OK]
oobsri/tomcat8                        Testing CI Jobs with different names.           0                                       
swisstopo/service-print-tomcat        backend tomcat for service-print "the true, …   0                                       
picoded/tomcat7                       tomcat7 with jre8 and MANAGER_USER / MANAGER…   0                                       [OK]
cfje/tomcat-resource                  Tomcat Concourse Resource                       0                                       
s390x/tomcat                          Apache Tomcat is an open source implementati…   0        

## 查找stars大於多少的鏡像
# docker search -s 30 tomcat
Flag --stars has been deprecated, use --filter=stars=3 instead
NAME                       DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
tomcat                     Apache Tomcat is an open source implementati…   2072                [OK]                
tomee                      Apache TomEE is an all-Apache Java EE certif…   56                  [OK]                
dordoka/tomcat             Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base…   49                                      [OK]
davidcaste/alpine-tomcat   Apache Tomcat 7/8 using Oracle Java 7/8 with…   30
## 下載鏡像 不加版本號則默認下載最新的鏡像(docker pull tomcat:latest)
# docker pull tomcat:8.0
8.0: Pulling from library/tomcat
f189db1b88b3: Pull complete 
3d06cf2f1b5e: Pull complete 
edd0da9e3091: Pull complete 
eb7768aae14e: Pull complete 
e2780f585e0f: Pull complete 
e5ed720afeba: Pull complete 
d9e134700cfc: Pull complete 
e4804b33d02a: Pull complete 
b9df0c24315e: Pull complete 
49fdae8eaa20: Pull complete 
1aea3d9a32e6: Pull complete 
Digest: sha256:8ecb10948deb32c34aeadf7bf95d12a93fbd3527911fa629c1a3e7823b89ce6f
Status: Downloaded newer image for tomcat:8.0

## 查看是否下載成功
# docker images -a
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              8.0                 ef6a7c98d192        3 weeks ago         356MB
hello-world         latest              4ab4c602aa5e        4 weeks ago         1.84kB
## 刪除鏡像 可加惟一鏡像名或鏡像id 不加版本號默認刪除latest 此處表示hello-world正在使用中
# docker rmi hello-world
Error response from daemon: conflict: unable to remove repository reference "hello-world" (must force) - container a163e0378c36 is using its referenced image 4ab4c602aa5e

## 強制刪除鏡像
# docker rmi -f hello-world
Untagged: hello-world:latest
Untagged: hello-world@sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Deleted: sha256:4ab4c602aa5eed5528a6620ff18a1dc4faef0e1ab3a5eddeddb410714478c67f

## 查看是否刪除成功
# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              8.0                 ef6a7c98d192        3 weeks ago         356MB

## 刪除多個鏡像 多個鏡像之間空格隔開便可
# docker rmi -f hello-world nginx
Untagged: hello-world:latest
Untagged: hello-world@sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
Deleted: sha256:4ab4c602aa5eed5528a6620ff18a1dc4faef0e1ab3a5eddeddb410714478c67f
Untagged: nginx:latest
Untagged: nginx@sha256:9ad0746d8f2ea6df3a17ba89eca40b48c47066dfab55a75e08e2b70fc80d929e
Deleted: sha256:be1f31be9a87cc4b8668e6f0fee4efd2b43e5d4f7734c75ac49432175aaa6ef9
Deleted: sha256:7609c40a03b852382a43d79231d9d4ca7661cd1ac9edcb46f78a44fff4ed59ca
Deleted: sha256:a2b6968c4326640dd5e9e22ddf6cebb61ba1a4b79a4ac8d194f93000c5a4c3e2
Deleted: sha256:8b15606a9e3e430cb7ba739fde2fbb3734a19f8a59a825ffa877f9be49059817

## 刪除全部鏡像 組合命令
# docker rmi -f $(docker images -q)
相關文章
相關標籤/搜索