Docker的镜像命令

帮助命令

docker version # 显示docker的版本信息
docker info # 显示docker的系统信息(比版本信息更加详细)
docker 命令 --help # 万能命令(相当于命令帮助文档)

docker 命令行的帮助文档地址 :https://docs.docker.com/reference/

镜像命令

docker images 查看镜像

docker images # 查看本地主机上的镜像
[root@LuoKing /]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    feb5d9fea6a5   6 months ago   13.3kB
# REPOSITORY: 镜像的仓库源
# TAG :镜像的版本
# IMAGE ID:镜像的ID
# CREATED :镜像的创建时间
# SIZE :镜像的大小

# 可选项
[root@LuoKing /]# docker images --help

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

List images

Options:
  -a, --all             Show all images (default hides intermediate images) #显示所有的镜像
  -q, --quiet           Only show image IDs # 只显示镜像的ID

docker search 搜索镜像

[root@LuoKing /]# docker search mysql  #搜索镜像
NAME                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                            MySQL is a widely used, open-source relation…   12424     [OK]       
mariadb                          MariaDB Server is a high performing open sou…   4787      [OK]       
......
[root@LuoKing /]# docker search --help

Usage:  docker search [OPTIONS] TERM

Search the Docker Hub for images

Options:
  -f, --filter filter   Filter output based on conditions provided # 更具条件查询(过滤)
  
举例:
[root@LuoKing /]# docker search mysql --filter=STARS=5000 #过滤少于5000start的mysql
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   12424     [OK]  

镜像下载

默认为最新版本
# docker pull (需要下载的软件)
指定版本下载
# docker pull mysql:5.7
[root@LuoKing /]# docker pull mysql:5.7
5.7: Pulling from library/mysql
72a69066d2fe: Pull complete  #分层下载,docker images 的核心 联合文件系统
93619dbc5b36: Pull complete 
99da31dd6142: Pull complete 
626033c43d70: Pull complete 
37d5d7efb64e: Pull complete 
ac563158d721: Pull complete 
d2ba16033dad: Pull complete 
0ceb82207cd7: Pull complete 
37f2405cae96: Pull complete 
e2482e017e53: Pull complete 
70deed891d42: Pull complete 
Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94 #签名
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7 #真实的下载地址

删除镜像

docker rmi IMAGEID
[root@LuoKing /]# docker rmi -f feb5d9fea6a5 # -f 为强制删除(也就这一个参数)
Untagged: hello-world:latest
Untagged: hello-world@sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412

docker rmi -f $(docker images -aq)# 删除全部镜像

容器命令

posted @ 2022-04-17 23:54  小罗要有出息  阅读(207)  评论(0)    收藏  举报