Docker容器常用命令以及镜像加载原理

本文详细介绍了Docker的常用命令,包括帮助命令、镜像命令、容器命令和其他常用命令,并深入讲解了Docker镜像是什么,重点阐述了Docker镜像加载的分层原理和UnionFS的工作方式,帮助读者理解Docker如何实现资源的高效利用。
摘要由CSDN通过智能技术生成

目录

帮助命令

镜像命令

容器命令

常用其他命令

Docker相关命令汇总

Docker镜像是什么

Docker镜像加载原理

Docker镜像的分层结构


帮助命令

Dokcer官方帮助文档地址:Redirecting…icon-default.png?t=M276https://docs.docker.com/engine/reference/commandline/

​​​​​​​docker -v 或 docker version        显示docker的版本信息

docker info                        显示docker的系统信息,包括镜像和容器的数量

docker 命令 --help                 帮助命令 

镜像命令

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

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

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

# 可选参数
  -a, --all             # 列出所有的镜像  --Show all images
  -q, --quiet           # 只显示镜像的id  --Only show image IDs

docker search        搜索镜像

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

# 可选参数,通过提供的条件来过滤
-f, --filter=STARS=3000    # 搜索出来的镜像就是STARS大于3000的
[root@docker ~]# docker search mysql --filter=STARS=3000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   11312     [OK]       
mariadb   MariaDB Server is a high performing open sou…   4299      [OK]

docker pull        下载镜像

# docker pull 镜像名[:tag]
[root@docker ~]# docker pull mysql
Using default tag: latest      # 如果不写tag,默认就是latest
latest: Pulling from library/mysql
bed879327370: Pull complete    # 分层下载,docker image的核心,联合文件系统 
03285f80bafd: Pull complete 
ccc17412a00a: Pull complete 
1f556ecc09d1: Pull complete 
adc5528e468d: Pull complete 
1afc286d5d53: Pull complete 
6c724a59adff: Pull complete 
0f2345f8b0a3: Pull complete 
c8461a25b23b: Pull complete 
3adb49279bed: Pull complete 
77f22cd6c363: Pull complete 
Digest: sha256:d45561a65aba6edac77be36e0a53f0c1fba67b951cb728348522b671ad63f926  # 签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest  # 真实地址

# 二者等价
docker pull mysql
docker pull docker.io/library/mysql:latest

# 指定版本下载
[root@docker ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
e1acddbe380c: Already exists 
bed879327370: Already exists 
03285f80bafd: Already exists 
ccc17412a00a: Already exists 
1f556ecc09d1: Already exists 
adc5528e468d: Already exists 
1afc286d5d53: Already exists 
4d2d9261e3ad: Pull complete 
ac609d7b31f8: Pull complete 
53ee1339bc3a: 
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

_SmallTownKid_

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

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

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

打赏作者

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

抵扣说明:

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

余额充值