现在有一个项目,其中用到了多个 Dockerfile,每个 Dockerfile 都会用到上一个,2.0,0 的第一行就是FROM test:1.0.0
,需要多次 build 才能得到最终的。
示例:
先执行 docker build -f cpu/1.0.0/Dockerfile -t test:1.0.0 .
再执行 docker build -f cpu/2.0.0/Dockerfile -t test:2.0.0 .
...
再执行 docker build -f cpu/2.0.6/Dockerfile -t test:2.0.6 .
目录树类似如下:
|-- cpu
| |-- 1.0.0
| | |-- Dockerfile
| | |-- READ.md
| | `-- run-noroot.sh
| |-- 2.0.0
| | |-- Dockerfile
| | |-- READ.md
| | |-- requirement-py2.txt
| | |-- requirement-py3.txt
| | `-- run-root.sh
| |-- 2.0.4
| | |-- Dockerfile
| | |-- READ.md
| | `-- run-root.sh
| |-- 2.0.5
| | |-- Dockerfile
| | |-- READ.md
| | |-- etc
| | | `-- sudoers
| | |-- notebook
| | | |-- __init__.py
| | `-- run-jupyter.sh
| `-- 2.0.6
| |-- Dockerfile
| `-- READ.md
这样的项目,如何执行一次命令构建出来。
我能想到两个方法,二是重写一个 Dockerfile,然后把其他的都整理进来,太麻烦; 二是用 Makefile 来做,还在尝试
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.