Docker学习笔记——常用命令(1)

本文详细介绍了Docker的基本操作,包括使用`docker version`和`docker info`查看版本和系统信息,使用`docker images`查看本地镜像,`docker search`搜索镜像,`docker pull`下载镜像,以及`docker rmi`删除镜像。通过实例演示了每个命令的用法,如搜索和下载MySQL镜像,以及如何删除镜像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

致敬 @遇见狂神说

自学课程地址:https://www.bilibili.com/video/BV1og4y1q7M4?p=1
以下为根据课程记录的笔记,可以作为参考但是建议,自己记录

安装系统:CentOS

Docker的常用命令

帮助命令

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

帮助文档地址:https://docs.docker.com/engine/reference/commandline/

镜像命令

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

[root@coder ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    feb5d9fea6a5   3 months ago   13.3kB

# 解释
REPOSITORY  镜像的仓库源
TAG         镜像的标签
IMAGE ID    镜像的id
CREATED     镜像的创建时间
SIZE        镜像的大小

#可选项
-a, --all             # 列出所有的镜像
-q, --quiet           # 只显示镜像的ID

docker search 搜索镜像

[root@coder ~]# docker search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   11912     [OK]       
mariadb                           MariaDB Server is a high performing open sou…   4558      [OK] 

# 可选项,通过收藏来过滤
--filter=STARS=3000     # 搜索出来的镜像就是STARS大于3000的

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

docker pull 下载镜像

# 下载镜像  docker pull 镜像名[:tag]
[root@coder ~]# docker pull mysql
Using default tag: latest   #如果不写tag,默认就是latest
latest: 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 
688ba7d5c01a: Pull complete 
00e060b6d11d: Pull complete 
1c04857f594f: Pull complete 
4d7cfa90e6ea: Pull complete 
e0431212d27d: Pull complete 
Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709     #签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest     #真实地址

# 等价于它
docker pull mysql
docker pull docker.io/library/mysql:latest

docker rmi 删除镜像

[root@coder ~]# docker rmi -f 镜像id    # 删除指定的镜像id
[root@coder ~]# docker rmi -f 镜像id 镜像id 镜像id  # 删除多个镜像
[root@coder ~]# docker rmi -f $(docker images -aq)  # 删除全部的镜像
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值