Kaniko在Gitlab流水线中重置构建上下文

huangapple go评论54阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年4月13日 19:10:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76004737.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定