如何解决“无法从泊坞窗检索.Id"?使用Jenkins管道构建Docker映像时 [英] How to resolve "Cannot retrieve .Id from docker" when building Docker image using Jenkins pipeline

查看:521
本文介绍了如何解决“无法从泊坞窗检索.Id"?使用Jenkins管道构建Docker映像时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Jenkins管道来构建Dockerfile.

I am using a Jenkins pipeline to build a Dockerfile.

泊坞窗文件成功完成了所有步骤,并创建了泊坞窗映像.

The dockerfile successfully goes through all steps, and creates the docker image.

如图所示:

Step 16/19 : FROM base AS final
 ---> <id>
Step 17/19 : WORKDIR /app
 ---> Using cache
 ---> <id>
Step 18/19 : COPY --from=publish /app .
 ---> Using cache
 ---> <id>
Step 19/19 : ENTRYPOINT ["", "myapp.dll"]
 ---> Using cache
 ---> <id>
Successfully built cb3y81938e88
Successfully tagged myapp:latest

但是,此后,shell失败并显示以下错误:

However, after this, the shell Fails with the following error:

java.io.IOException: Cannot retrieve .Id from 'docker inspect base AS final'

尽管成功构建了docker镜像,为什么它仍会引发此错误? 当我在本地计算机上执行此操作时,命令在已成功标记myapp:latest"上退出

Why does it throw this error despite the docker image successfully built? When I execute this on my local machine, the command exits on "Successfully tagged myapp:latest"

我的docker版本是18.03.1-ce.

My docker version is 18.03.1-ce.

在此问题上的任何帮助将不胜感激!

Any help on this issue would be greatly appreciated!

推荐答案

该Jenkins插件似乎存在错误.

It seems that there is a bug in that Jenkins plugin.

您可以尝试删除多阶段构建名称(不需要时为"AS final"):

You can try removing multi stage build name ("AS final" as you don't need it):

FROM base
(....)

但是,如果您确实需要引用先前构建的映像(多阶段),则可以使用--copy-from 0(对应的是0,1,2,而不是别名)来解决此问题.

But if you really need to reference a previous built image (multi stage), a workaround can be using --copy-from 0 (0,1,2 as it corresponds, instead of the alias name)

詹金斯相关问题

  • https://issues.jenkins-ci.org/browse/JENKINS-44789
  • https://issues.jenkins-ci.org/browse/JENKINS-44609
  • https://issues.jenkins-ci.org/browse/JENKINS-31507

修改

在此处记录OP找到的解决方案:

Documenting here the solution found by the OP:

我通过不使用Jenkinsfile管道文件来工作,而是在Jenkins作业中执行Shell来执行Docker build命令. (docker build -t Latest-build.)

I got this working by not using the Jenkinsfile pipeline file, but instead executing a Shell within the Jenkins job to execute the Docker build command. (docker build -t latest-build .)

这篇关于如何解决“无法从泊坞窗检索.Id"?使用Jenkins管道构建Docker映像时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆