看板 Linux 關於我們 聯絡資訊
各位達人好 本人在 host machine 的/root/test目錄加入一個submodule (這裡以matplotlib為例): cd /root/test git submodule add https://github.com/matplotlib/matplotlib.git sm/matplotlib 然後同樣在/root/test中寫了一個簡單的Dockerfile (sub.Dockerfile) FROM debian:buster RUN apt-get update && apt install -qy git RUN --mount=type=bind,source=sm/matplotlib,target=/root/sm/matplotlib,rw 建立image (test_sm) 並進入container: docker build -t test_sm -f /root/test/sub.Dockerfile . docker run -it test_sm 卻發現在container中的/root/sm/matplotlib完全沒有東西,host machine中的 sm/matplotlib 好像沒有 mount 到 container中 請問大家有碰過類似的事嗎? 感謝各位看完我的問題 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 47.187.207.248 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1679559967.A.CE9.html
yvb: 不了解您的意思. Dockerfile 是建立 docker image 時用的, 03/23 17:02
yvb: 其中的 RUN 後面是執行什麼 outcall 命令, 就像 apt-get .... 03/23 17:04
yvb: 你要 mount 應該是在 docker run 後面加參數. 03/23 17:04
yvb: 建立 docker image 是指 docker build ... 那一句. 03/23 17:07
VivianAnn: FROM和RUN都是dockerfile中的內容,我是在dockerfile 03/23 21:40
VivianAnn: 中mount 03/23 21:40
lycantrope: 建立時本來就沒再mount 要run時候才mount 03/23 21:44
VivianAnn: 不太懂,我是在run container後發現sm/matplotlib裡面 03/23 22:31
VivianAnn: 沒東西,這樣正常嗎 03/23 22:31
CP64: 這正常 因為那是 build 時 mount 進去的 03/23 22:34
CP64: 那個 mount 在跑完那一行 RUN 時就會 unmount 了 03/23 22:35
CP64: 你想要在 docker run 時使用的話還是要用 -v 指定 03/23 22:35
Typebrook: 正確來說,RUN 後面本來就是接 executable file 03/24 00:46
Typebrook: 文件要看啦: 03/24 00:47
Typebrook: docs.docker.com/engine/reference/builder/#run 03/24 00:47
VivianAnn: 感謝各位,我的底子差,,比較抓不到方向 03/25 08:01
iwant2sleep: 試著在sm/matplotlib裡下以下指令: 03/26 00:21
iwant2sleep: git submodule init && git submodule update 03/26 00:21
iwant2sleep: 然後再mount 03/26 00:21
yvb: 請問原PO在哪看到 --mount... 那一句而抄來用的? 03/27 20:37
lycantrope: 原PO去年就問docker了,都快一年過去應該沒時間學吧 03/28 11:20
firejox: copy不好嗎 04/04 10:58