是否可以在Docker构建中运行命令而无需创建新图层。
例如
FROM nginx:alpine
COPY default.conf /etc/nginx/conf.d
# the following would be like RUN but won't create a layer, it is just used to verify that the build is okay so far.
TEST nginx -t
答案 0 :(得分:1)
不,据我所知。
引用Dockerfile引用:RUN
指令将在当前图像之上的新图层中执行任何命令并提交结果。生成的已提交映像将用于Dockerfile中的下一步。
多阶段构建可以帮助保持图像整洁。多阶段构建背后的想法是放弃任何不必要的中间工件。
文档:https://docs.docker.com/develop/develop-images/multistage-build/
来自Docker博客的多阶段构建简介:https://blog.docker.com/2017/07/multi-stage-builds/