尤川豪   ·  1年前
445 貼文  ·  275 留言

Docker notes 2022

docker hub 的 IMAGE LAYERS 資訊好像沒啥用處

FROM nginx:latest

COPY index.html /usr/share/nginx/html
COPY linux.png /usr/share/nginx/html

EXPOSE 80 443   

CMD ["nginx", "-g", "daemon off;"]

連 FROM 都沒有,想看 base image 都沒辦法欸

有辦法在 docker hub 看到 Dockerfile 嗎

As far as I know, no, you can't. Because a Dockerfile is used for building the image, it is not packed with the image itself.

那 Docker hub 的 image layers 是有什麼用?

That Docker Hub history view doesn't show the actual Dockerfile; instead, it shows content essentially extracted from the docker history of the image. That doesn't preserve the specific details you're looking for: it doesn't remember the names of base images, or the build-context file names of things that get ADDed or COPYed in.

Conclusions

  • 有點像是 composer.json vs composer.lock 以及 package.json vs package-lock.json
  • 一個是給開發者看的,一個是給機器看的(也不是,畢竟都在網頁上給人看了,應該說是剝開一層抽象啦)
  • 難道說,FROM 就是很無腦的把 base image 的一串 Docker 指令 copy & paste 過來?
  • 反正,到最後,本來就是一整串 linux commands 到處貼來貼去吧

More

  分享   共 561 次點閱
按了喜歡:
共有 1 則留言
Kevin Hou   ·  1年前
4 貼文  ·  20 留言

而且 base image 的 docker image 還很常會有自己的指令
像 php-8.0:fpm 其實就事先裝了一些系統級套件跟幫忙設定基本的 php 生態系
保險起見稍微瞄一下 base image 的 git repository 會比較知道它到底做了哪些事

 
您的留言
尤川豪
445 貼文  ·  275 留言

Devs.tw 是讓工程師寫筆記、網誌的平台。隨手紀錄、寫作,方便日後搜尋!

歡迎您一起加入寫作與分享的行列!

查看所有文章