Tianchi YU's Blog

每日笔记 - 2024.05.07

0

| 摘录


Tangent: In my opinion, understanding how a technology works under the hood is the best way to achieve learning speed and to build confidence that you are using the tool in the correct way. Often a technology is released with a certain breathless hype that make it difficult to really understand appropriate usage patterns. More specifically, technology releases often develop an abstraction model that can invent new terminologies and metaphors that might be useful at first, but make it harder to develop mastery in the latter stages.

A good example of this is Git. I could not gain traction with Git until I understood its underlying model, including trees, blobs, commits, tags, tree-ish, etc. I had written about this before in a previous post, and still remain convinced that people who don't understand the internals of Git cannot have true mastery of the tool.


1

| 技术


通过不断的docker commit和docker create产生新的images和containers,images的大小会越来越大,即使我在docker commit时不做任何新的操作? ChatGPUT: 是的,这是 Docker 的一个特性。每次执行 docker commit 时,都会创建一个新的镜像层,即使你没有对容器做出任何改变。这是因为 Docker 使用一种称为联合文件系统(Union File System)的技术来构建镜像。在联合文件系统中,每个 Docker 镜像都由一系列文件系统层叠加而成。当你对容器进行修改并提交时,Docker 会创建一个新的文件系统层,该层包含了你的更改,然后这个新的文件系统层会与原始镜像的层叠加在一起,形成一个新的镜像。

因此,即使你没有在容器中做出任何更改,每次提交都会创建一个新的镜像层,这会导致镜像的大小不断增加。要减少镜像的大小,你可以考虑使用 Dockerfile 来构建镜像,这样可以避免不必要的层叠加,或者使用 docker export 和 docker import 来创建不包含历史记录的镜像。


#note