5

觀察 Docker image 每一層變化的 dive,以及操作的 crane

 8 months ago
source link: https://blog.gslin.org/archives/2024/01/09/11573/%e8%a7%80%e5%af%9f-docker-image-%e6%af%8f%e4%b8%80%e5%b1%a4%e8%ae%8a%e5%8c%96%e7%9a%84-dive%ef%bc%8c%e4%bb%a5%e5%8f%8a%e6%93%8d%e4%bd%9c%e7%9a%84-crane/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

觀察 Docker image 每一層變化的 dive,以及操作的 crane

在「Dive: A tool for exploring a Docker image, layer contents and more (github.com/wagoodman)」這邊看到的工具,官網在 GitHub 上:「wagoodman/dive」。

Docker image 是一層一層疊起來的,而 dive 可以翻出每一層的變化:

A tool for exploring a docker image, layer contents, and discovering ways to shrink the size of your Docker/OCI image.

1704802755.gif

馬上想得到的用途是拿來分析空間的使用情況,另外可以拿來確認 container 裡面的內容 (就不用 /bin/bash 進去看了)。

在留言 id=38915336 這邊另外提到了 crane 這個有趣的的東西,可以操作 Docker image。

這邊看到的說明包括了合併不同的 layer,以及類似 Gitrebase 功能 (re-apply diff):

For image and layer manipulation, crane is awesome - as is the underlying go-containerregistry library.

It lets you add new layers, or edit any metadata (env vars, labels, entrypoint, etc) in existing images. You can also "flatten" an image with multiple layers into a single layer. Additionally you can "rebase" an image (re-apply your changes onto a new/updated base image). It does all this directly in the registry, so no docker needed (though it's still useful for creating the original image).

https://github.com/google/go-containerregistry/blob/main/cmd/crane/recipes.md

(updated: better link)

兩個剛好搭在一起...

Related

如何做出好的 Docker Image

Docker 愈來愈紅,而 image 也愈來愈多,於是就有人討論要如何做出好的 Docker image。 在「Building good docker images」這篇文章裡提到了不少現象以及改善的技巧。 首先是 base image 的選用。除非有特別的理由,不然作者建議是基於 debian:wheezy (85MB) 而非 ubuntu:14.04 (195MB)。甚至在某些極端的情況下,你可以選擇 busybox (2MB)。 再來是沒事不要塞 build tools 進去,除非那是之後執行必要的東西。 然後是避免暫存檔的產生,作者舉的例子還蠻容易懂的。這樣是 109MB: FROM debian:wheezy RUN apt-get update && apt-get install -y wget RUN wget http://cachefly.cachefly.net/10mb.test RUN rm 10mb.test 而這樣只有 99MB,原因是每一個 RUN 都會疊一層上去: FROM debian:wheezy RUN…

November 9, 2014

In "Computer"

在 Docker 裡面跑 GUI 程式的點子

昨天的 Hacker News Daily 上看到「Running GUI apps within Docker containers」這篇文章,裡面想要把程式包到 Docker container 裡面,然後給了一些想法,另外在「Running GUI apps within Docker containers (trickster.dev)」這邊也有一些討論與想法可以看。 要注意的是,這邊主要是以 X11 類的環境為主 (所以應該還是 Linux 了),而文章是用 Firefox 當例子,不過主要應該還是會拿來跑其他的東西... 看起來 GUI 的部份主要就是先用 VNC + x11vnc 打通到 host 的 X11 環境,這邊會需要 xhost 開授權讓 container 內的程式可以控制 X11 的環境 (話說他範例裡面直接開 xhost + 也真讚)。 後面提到的 noVNC…

March 28, 2022

In "Computer"

a611ee8db44c8d03a20edf0bf5a71d80?s=49&d=identicon&r=gAuthor Gea-Suan LinPosted on January 9, 2024Categories Computer, Murmuring, SoftwareTags container, crane, dive, docker, image

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)

Post navigation


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK