Docker常用的镜像image命令
帮助命令
docker version #显示docker的版本信息
docker info #显示docker的系统信息,包括镜像和容器的数量
docker 命令 --help #万能命令 #用–help查看命令和参数
https://docs.docker.com/reference/ #跟命令有关的官网帮助文档
https://hub.docker.com/ docker hub
镜像命令
docker images 查看所有本地的主机上的镜像
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 12 months ago 13.3kB
#解释
REPOSITORY 镜像的仓库源
tag 镜像的标签
image ID 镜像的id
CREATED 镜像的创建时间
#可选项
-a, --all 显示所有的镜像
-f, --filter filter Filter output based on conditions provided
-q, --quiet 只显示镜像的ID
docker search 搜索镜像
https://hub.docker.com/ 在 docker hub 可以查看到镜像的版本,简单介绍和使用方法
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 10339 [OK]
#可选项,通过收藏数量来过滤
--filter=STARS=3000 #搜索出来的镜像,收藏数量大于3000
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker search mysql --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 10339 [OK]
mariadb MariaDB is a community-developed fork of MyS… 3832 [OK]
docker pull 下载镜像
docker pull imageName:版本号
// A code block
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker pull mysql #不指定版本时,默认下载最新版本的Mysql
Using default tag: latest
latest: Pulling from library/mysql
6ec7b7d162b2: Pull complete #分层下载,docker image 的核心,联合文件系统
fedd960d3481: Pull complete
7ab947313861: Pull complete
64f92f19e638: Pull complete
3e80b17bff96: Pull complete
014e976799f9: Pull complete
59ae84fee1b3: Pull complete
ffe10de703ea: Pull complete
657af6d90c83: Pull complete
98bfb480322c: Pull complete
6aa3859c4789: Pull complete
1ed875d851ef: Pull complete
Digest: sha256:78800e6d3f1b230e35275145e657b82c3fb02a27b2d8e76aac2f5e90c1c30873 #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest #真实地址
#等价于它
docker pull mysql
docker pull docker.io/library/mysql:latest
#下载指定版本的mysql镜像
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker pull mysql:5.7
5.7: Pulling from library/mysql
6ec7b7d162b2: Already exists #共用的层级不用下载
fedd960d3481: Already exists
7ab947313861: Already exists
64f92f19e638: Already exists
3e80b17bff96: Already exists
014e976799f9: Already exists
59ae84fee1b3: Already exists
7d1da2a18e2e: Pull complete
301a28b700b9: Pull complete
529dc8dbeaf3: Pull complete
bc9d021dc13f: Pull complete
Digest: sha256:c3a567d3e3ad8b05dfce401ed08f0f6bf3f3b64cc17694979d5f2e5d78e10173
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
docker rmi 删除镜像
docker rmi -f f07dfa83b528 #通过imageID 删除单个image
docker rmi -f $(docker images -aq) #删除全部的镜像
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 f07dfa83b528 12 days ago 448MB
mysql latest a347a5928046 12 days ago 545MB
hello-world latest bf756fb1ae65 12 months ago 13.3kB
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker rmi -f f07dfa83b528 #通过imageID 删除单个image
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker rmi -f imageID1 imageID2 #删除多个镜像
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker rmi -f $(docker images -aq) #删除全部的镜像
Untagged: mysql:latest
Untagged: mysql@sha256:78800e6d3f1b230e35275145e657b82c3fb02a27b2d8e76aac2f5e90c1c30873
Deleted: sha256:a347a59280467629ae4d70ce555e3f96faca8ff2ff8c57cacc8184bebb681f66
Deleted: sha256:8c4db4ce0f63c9eec74a2e555bb7e2fa5e2de08389cbc747793aa30bc3ac04e1
Deleted: sha256:6179be2adc547662cd0ef2cb032b85809ac68923b7ab9c71e5a21b88bbe7f542
Deleted: sha256:17d702350e6aa7f240ca23090d24b059f5c324e292a77b5069225e76e0b51dd6
Deleted: sha256:5c5f95733957fd96300b5265d6b2df728415ed62e7b4b30eadd7d836d48187bf
Deleted: sha256:fbf118fadaf5230c8df9a3b51c608393a8f3adb99c089ea2db253438efab1a0e
Deleted: sha256:43b82d704a10e6d022fa3f31a5f827a00e339ee21dd2849a9b120ab82be9af71
Deleted: sha256:a4994702421d2b9a74c4f3810aa7ac09990e849905f23a1d8f358c826d58501f
Deleted: sha256:36c598c7a6f90abf6d67cde4a58b0747bfbcc7441d3b782bdeea7cda8c9ad7b6
Deleted: sha256:86f598b4f8200bdd4ae752f916154e4e29d5b4c211bb124eb150b9957a3e0141
Deleted: sha256:9e979d97f92bf78a225c77c6b4ba74eb2e03efb95b19b69206cd17cee15a4b26
Deleted: sha256:aff48ce4678f78d83d7e9bfb9e88cd951c3da52da08779e99b6082edd1cc66f3
Deleted: sha256:87c8a1d8f54f3aa4e05569e8919397b65056aa71cdf48b7f061432c98475eee9
Untagged: hello-world:latest
Untagged: hello-world@sha256:1a523af650137b8accdaed439c17d684df61ee4d74feac151b5b337bd29e7eec
Deleted: sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b
[root@iZwz9e60ytsp3m74u1cqhoZ /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@iZwz9e60ytsp3m74u1cqhoZ /]#