Jenkins-Run Docker:COPY失败:stat/var/lib/docker/tmp/docker-builder ...:没有这样的文件或目录 [英] Jenkins-Run Docker: COPY failed: stat /var/lib/docker/tmp/docker-builder...: no such file or directory

查看:2947
本文介绍了Jenkins-Run Docker:COPY失败:stat/var/lib/docker/tmp/docker-builder ...:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其他 问题 关于 问题,我已经查看了我在Google搜索中可以找到的有关此错误消息的所有资源,但没有一个对我有用.

There are many other questions about this issue, and I've looked at every resource I can find in a google search about this error message, but none of them have worked for me.

我正在使用Jenkins作业来自动化容器的构建/推送.为此,我使用"Execute Shell"构建步骤,并在内部进行所有Docker配置(我尝试使用管道,但这些操作在我团队的Jenkins配置中不起作用;请在这个问题的范围).这项工作首先克隆了一个git存储库(myrepo),然后我有一个Shell脚本编写了一些我想包含在Docker容器中的文件(例如run.sh)以及一个Dockerfile.

I'm using a Jenkins job to automate the build/push of a container. To do so, I'm using the "Execute Shell" build step, and doing all of my Docker configuration within (I've tried using a pipeline, but those just don't work in my team's Jenkins configuration; consider them outside the scope of this question). The job first clones a git repository (myrepo), and then I have a shell script write a number of files that I want to include in the Docker container (e.g. run.sh), as well as a Dockerfile.

在构建失败时,我的Jenkins工作区的文件夹结构如下:

The folder structure of my Jenkins workspace is as follows, by the time the build fails:

|-- myrepo/
|   |-- myexe            # executable file
|   |-- testfiles/
|   |   |-- file1.txt
|   |   |-- file2.txt
|   |   |-- ...
|-- run.sh
|-- Dockerfile

我没有.dockerignore文件.

在构建失败时,Dockerfile看起来像这样:

The Dockerfile, by the time the build fails, looks like this:

FROM centos
USER root
# create directories
RUN mkdir -p /opt/dir1/myexe
# copy shell script
COPY run.sh /usr/bin/runprog
# copy executable
COPY myrepo/myexe /opt/dir1/myexe/       # fails on this line
COPY myrepo/testfiles /opt/dir1/myexe/
# final setup 
WORKDIR /opt/dir1/myexe/
CMD ["/opt/dir1/myexe/myexe"]

现在,在Jenkins上,在较早导入回购协议之后,我将在执行Shell"构建步骤中执行所有这些操作.我在此步骤中使用echo和输出重定向来创建run.shDockerfile.在詹金斯(Jenkins)的执行外壳"(Execute Shell)构建步骤中执行的外壳脚本如下所示:

Now, on Jenkins, I'm executing this all in the "Execute Shell" build step, after having imported the repo earlier. I create run.sh and Dockerfile during this step, using echo and output redirection. The shell script being executed in Jenkins's "Execute Shell" build step looks something like this:

echo '#!/bin/sh
...
' > run.sh

echo 'FROM centos
...
' > Dockerfile

docker system prune -af
docker images           # I can confirm from logs that no images remain
docker build -t containername:${DOCKER_IMAGE_TAG} .

但是当我运行此命令时,该docker build命令的构建失败:

But when I run this, the build fails on that docker build command:

Step 5/8 : COPY myrepo/myexe /opt/dir1/myexe
COPY failed: stat /var/lib/docker/tmp/docker-builder190297994/opt/dir1/myexe: no such file or directory

我所见过的其他任何问题均未提供有助于解决问题的解决方案.我的文件在本地存在,构建失败后可以在Jenkins工作区中看到.我的文件位于.目录中的本地 中,可以通过将pwdls放在docker build命令之前来确认.我没有.dockerignore文件,因此Docker不应该忽略任何内容.但是我一定想念一些东西,因为不管我想尝试什么,它仍然无法正常工作.

None of the other questions I've seen have solutions that have helped. My files exist locally, which I can see in the Jenkins workspace after the build fails. My files exist locally in the . directory, which I can confirm by putting pwd and ls just before the docker build command. I don't have a .dockerignore file, so Docker shouldn't be ignoring anything. But I must be missing something, as it's still not working no matter what I think to try.

我俯瞰什么?

(Docker版本为Docker version 18.09.7, build 2d0083d)

(Docker version is Docker version 18.09.7, build 2d0083d)

推荐答案

您的评论# fails on this line是问题. 根据Docker文档:

Your comment # fails on this line is the problem. As per the Docker documentation:

Docker将以#开头的行视为注释,除非该行是 有效的解析器指令.行中其他任何地方的#号标记是 视为论点.

Docker treats lines that begin with # as a comment, unless the line is a valid parser directive. A # marker anywhere else in a line is treated as an argument.

此处的更多信息: https://docs.docker.com/engine/参考/builder/#format

这篇关于Jenkins-Run Docker:COPY失败:stat/var/lib/docker/tmp/docker-builder ...:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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