Docker常用镜像命令

1.帮助命令

docker version        # docker的版本信息
docker info              # 显示docker的系统信息,包括镜像和容器的数量
docker --help         # 帮助命令,查看所有
docker 命令 --help     # 帮助命令,查看指定的

2.镜像命令

docker images:查看所有本地的主机上的镜像

[root@SUIAB suiab]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   latest    feb5d9fea6a5   10 months ago   13.3kB
--------------------------------------------------------------
参数解释:
REPOSITORY    镜像的仓库源
TAG            镜像的标签
IMAGE ID    镜像的id
CREATED        镜像的创建时间
SIZE        镜像的大小
-------------------------------------------------------------
命令参数可选项:
 -a, --all         # 显示所有镜像 (docker images -a)
 -q, --quiet       # 仅显示镜像id (docker images -q)

docker search:搜索镜像

[root@SUIAB suiab]# docker search mysql
NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                           MySQL is a widely used, open-source relation…   12983     [OK]       
mariadb                         MariaDB Server is a high performing open sou…   4973      [OK]       
phpmyadmin                      phpMyAdmin - A web interface for MySQL and M…   594       [OK]       
percona                         Percona Server is a fork of the MySQL relati…   583       [OK]       

-----------------------------------------------------------
命令参数可选项 (通过搜索来过滤)
--filter=STARS=3000     # 搜索出来的镜像就是stars大于3000的

[root@SUIAB suiab]# docker search mysql --filter=STARS=3000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   12983     [OK]       
mariadb   MariaDB Server is a high performing open sou…   4973      [OK]     

docker pull:下载镜像

[root@SUIAB suiab]# docker pull mysql #不指定版本默认是最新版,指定版本用tag
Using default tag: latest
latest: Pulling from library/mysql
32c1bf40aba1: Pull complete     # 分层下载,docker image的核心
3ac22f3a638d: Pull complete 
b1e7273ed05e: Pull complete 
20be45a0c6ab: Pull complete 
410a229693ff: Pull complete 
1ce71e3a9b88: Pull complete 
c93c823af05b: Pull complete 
c6752c4d09c7: Pull complete 
d7f2cfe3efcb: Pull complete 
916f32cb0394: Pull complete 
0d62a5f9a14f: Pull complete 
Digest: sha256:ce2ae3bd3e9f001435c4671cf073d1d5ae55d138b16927268474fc54ba09ed79    #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest    # 真实地址

-----------------------------------------------------------
# 两个命令是等价的
docker pull mysql
docker pull docker.io/library/mysql:latest

指定版本下载
[root@SUIAB suiab]#  docker pull mysql:5.7

[root@SUIAB suiab]#  docker pull mysql:5.7
5.7: Pulling from library/mysql
66fb34780033: Pull complete 
ef4ccd63cdb4: Pull complete 
d6f28a94c51f: Pull complete 
7feea2a503b5: Pull complete 
71dd5852ecd9: Pull complete 
2ff5c3b24fd5: Pull complete 
88a546386a61: Pull complete 
65b18297cf83: Pull complete 
d64f23335fb8: Pull complete 
6ba4171261fa: Pull complete 
96dcc6c8de93: Pull complete 
Digest: sha256:b3a86578a582617214477d91e47e850f9e18df0b5d1644fb2d96d91a340b8972
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

docker rmi:删除镜像

[root@SUIAB suiab]# docker rmi -f 镜像id                    # 删除指定的镜像
[root@SUIAB suiab]# docker rmi -f 镜像id 镜像id 镜像id    # 删除多个镜像(空格分隔)
[root@SUIAB suiab]# docker rmi -f $(docker images -aq)    # 删除全部的镜像

[root@SUIAB suiab]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
mysql         latest    7b94cda7ffc7   4 days ago      446MB
mysql         5.7       3147495b3a5c   12 days ago     431MB
hello-world   latest    feb5d9fea6a5   10 months ago   13.3kB
[root@SUIAB suiab]# docker rmi -f 3147495b3a5c
Untagged: mysql:5.7
Untagged: mysql@sha256:b3a86578a582617214477d91e47e850f9e18df0b5d1644fb2d96d91a340b8972
Deleted: sha256:3147495b3a5ce957dee2319099a8808c1418e0b0a2c82c9b2396c5fb4b688509
Deleted: sha256:326f57ec4510699d8f5e3286acab31c7fc5ff52030615178fc61a4e4e2666792
Deleted: sha256:d5d890fe2493dddb27d7a9afe6efc2deab86a3d0d14bb55d61130ea92552234d
Deleted: sha256:7fe3127c1b80dad856024ddbe4962beaadc360578de21cc24ff3f65898472ded
Deleted: sha256:dff3729e0a6b6be8c74937ee796802973b5b4164042d517174a57026b77c8c60
Deleted: sha256:f80a7c9d6763bc45d9f4a75b54304b9bb801d5c87d0848a22229f62a5b7a9dfc
Deleted: sha256:27e299d6421f0c88f5f5c82cac2f51884e28351240838cd835a133628a1b03bc
Deleted: sha256:9c23e82c5e50b4a1ba1978cb47a5028061609ddd0057c774bbf722e4b518a7c6
Deleted: sha256:23da32aa7c7218232a08036f50e8e60417f89d172a8381309e221680497e223f
Deleted: sha256:5a7d5cbcd5f100b4e3f3ce6f53766ca33c6464e86e29f6da96a070f9cd3deab2
Deleted: sha256:8a6b5d70d43734f669f9c99f8c0d92923520787eca7c91a7a161d0a7064d85c8
Deleted: sha256:9ba403017e5ec778c95a5c4673f9d9c36ddf94e30fcb47959142a9e89d6606ea
[root@SUIAB suiab]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
mysql         latest    7b94cda7ffc7   4 days ago      446MB
hello-world   latest    feb5d9fea6a5   10 months ago   13.3kB

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

String_name_null

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值