Docker history命令
本文将介绍Docker的history命令,history命令用来显示镜像创建的历史记录信息。
docker history命令用来显示镜像创建的历史记录信息。帮助信息如下:
[root@localhost ~]# docker history --help
Usage: docker history [OPTIONS] IMAGE
Show the history of an image
Options:
--format string Pretty-print images using a Go template
-H, --human Print sizes and dates in human readable format (default true)
--no-trunc Don't truncate output
-q, --quiet Only show numeric IDs其中:
--format string 使用Go模板打印漂亮的图像列表
-H, --human 以人类可读格式打印大小和日期(默认为true)
--no-trunc 不截断输出
-q, --quiet 只显示数字ID
实例1:查看ubuntu镜像的历史信息。如下:
[root@localhost ~]# docker history ubuntu
IMAGE CREATED CREATED BY SIZE COMMENT
4c108a37151f 4 weeks ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 4 weeks ago /bin/sh -c mkdir -p /run/systemd && echo 'do… 7B
<missing> 4 weeks ago /bin/sh -c set -xe && echo '#!/bin/sh' > /… 745B
<missing> 4 weeks ago /bin/sh -c [ -z "$(apt-get indextargets)" ] 987kB
<missing> 4 weeks ago /bin/sh -c #(nop) ADD file:4e6b5d9ca371eb881… 63.2MB实例2:查看指定tag的镜像历史信息。如下:
[root@localhost ~]# docker history centos:6.7
IMAGE CREATED CREATED BY SIZE COMMENT
9f1de3c6ad53 4 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 4 months ago /bin/sh -c #(nop) LABEL License=GPLv2 0B
<missing> 4 months ago /bin/sh -c #(nop) LABEL Vendor=CentOS 0B
<missing> 4 months ago /bin/sh -c #(nop) ADD file:c6a7eec8d88e4caed… 191MB
<missing> 9 months ago /bin/sh -c #(nop) MAINTAINER The CentOS Pro… 0B实例3:查看我们自己构建镜像的历史信息。Dockerfile如下:
# 继承基础镜像centos:latest
FROM centos
# 设置作者信息
MAINTAINER myName<myName@163.com>
# 定义环境变量
ENV mypath /tmp
WORKDIR $mypath
# 安装 vim 和 ifconfig
RUN yum -y install vim
RUN yum -y install net-tools
# 暴露80端口
EXPOSE 80
CMD echo $mypath
CMD echo "success-------------------------ok"
CMD /bin/bash使用“docker build myimage:v1.0 .”命令根据Dockerfile构建镜像。然后使用“docker history myimage:v1.0”命令查看镜像历史信息,如下:
[root@localhost ~]# docker history myimage:v1.0
IMAGE CREATED CREATED BY SIZE COMMENT
729e175d50db 18 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "/bin… 0B
a5a1d43de63e 18 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B
1bebe4e64a58 18 minutes ago /bin/sh -c #(nop) CMD ["/bin/sh" "-c" "echo… 0B
b1f8be9fbfab 18 minutes ago /bin/sh -c #(nop) EXPOSE 80 0B
9056bf940f16 18 minutes ago /bin/sh -c yum -y install net-tools 105MB
f3763706802c 18 minutes ago /bin/sh -c yum -y install vim 160MB
f5e34ba2d527 18 minutes ago /bin/sh -c #(nop) WORKDIR /tmp 0B
15592795a5c9 18 minutes ago /bin/sh -c #(nop) ENV mypath=/tmp 0B
95489bc8a299 18 minutes ago /bin/sh -c #(nop) MAINTAINER myName<myName@… 0B
9f38484d220f 4 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B
<missing> 4 months ago /bin/sh -c #(nop) LABEL org.label-schema.sc… 0B
<missing> 4 months ago /bin/sh -c #(nop) ADD file:074f2c974463ab38c… 202MB仔细将历史信息和Dockerfile文件进行比对,返现就是我们Dockerfile中的每一条命令。上面的每一行代表的镜像的一层,镜像就是一个“花卷”,一层层组成的。
在年轻人的颈项上,没有什么东西能比事业心这颗灿烂的宝珠更迷人的了。 —— 哈菲兹
说说我的看法 -
还可使用 Gitee / GitHub 账号一键登录,与大家分享你的观点
立即登录
全部评论()
没有评论
- Docker安装Oracle 19c企业版详细教程:从拉取镜像到DBeaver连接数据库
- Docker 安装 IBM DB2 数据库教程:从快速安装到可视化连接(DBeaver)
- Docker 安装 RabbitMQ 消息中间件详细步骤(含管理界面配置与验证)
- Docker 安装 SQL Server 2022 最新版:最简单稳定、国内极速的完整教程
- Docker安装Jupyter服务:Ubuntu/CentOS一键部署Jupyter Lab教程
- Docker安装MongoDB详细步骤:从拉取镜像到数据持久化完整指南
- 如何在 Debian 中安装 Docker 容器引擎
- docker 安装 Qdrant 向量数据库
- Ubuntu22 LTS 使用 Docker 28.0.1 运行 tomcat 8.5 出现中文乱码
- IDEA 连接到远程服务器 Docker