【发布时间】:2020-06-04 18:18:40
【问题描述】:
1。场景 与 ONBUILD
基地Dockerfile
FROM ubuntu:latest
RUN apt-get update && apt-get install python3
ONBUILD COPY test.py test.py
很明显,当我们在Dockerfile(test-image:latest) 之上构建时,COPY 不会受到影响。(test.py 未复制)
现在开始构建Dockerfile
FROM test-image:latest
现在,当我们在Dockerfile 之上构建时,COPY 会影响,复制test.py
2。没有ONBUILD的场景
我不用ONBUILD也能达到同样的效果
基地Dockerfile
FROM ubuntu:latest
RUN apt-get update && apt-get install python3
在Dockerfile之上构建具有python3(test-image2:latest)的docker镜像
现在子 docker 镜像Dockerfile
FROM test-image2:latest
COPY test.py /test.py
所以,我的问题是,我为什么要使用ONBUILD 或者什么时候应该使用?有什么性能差异
【问题讨论】:
标签: docker dockerfile docker-build