英文:
Kaniko reset build context in Gitlab pipeline
问题
我在GitLab CI中使用Kaniko检测到以下问题:
假设我有这个Dockerfile:
FROM nginx:latest
RUN mkdir test
现在我想从这个Dockerfile创建两个镜像。但在构建第二个镜像时,它失败并显示该目录已经创建。
我认为这个问题与Kaniko的构建上下文有关。
您有没有办法在单个流水线作业中仍然使用Kaniko构建多个镜像的想法?
英文:
I detected following problem with Kaniko in GitLab CI:
Lets say I have this Dockerfile:
FROM nginx:latest
RUN mkdir test
Now I want to create two images from this Dockerfile. When building the second image it fails saying that the directory has been created already.
I think the reson of this has something to do with kanikos build context.
Do you have an idea how I can still build multiple images inside a single pipeline job using Kaniko?
答案1
得分: 1
以下是您要翻译的内容:
虽然它可能与Kaniko构建上下文相关(因为它不依赖于Docker守护程序,并在用户空间中完全执行Dockerfile中的每个命令),一个简单的解决方案是:
RUN mkdir -p test
这样,即使test已经存在,它也不会在错误中失败。
英文:
While it might be linked to the Kaniko build context (since it does not depend on a Docker daemon and executes each command within a Dockerfile completely in userspace), a simple solution would be:
RUN mkdir -p test
That way, even if test already exist, it won't fail in error.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论