Docker:处理tar文件时出错(退出状态1):设置pivot dir时出错:不是目录

问题描述:

我是Docker的新手,不知道是什么导致这个错误或如何诊断它。任何具体的帮助,这个问题或提示,首先检查这种类型的问题将是非常感谢!

I am new to Docker, and don't know what is causing this error or how to diagnose it. Any specific help with this problem or tips on where to check first to diagnose this type of problem would be much appreciated!

我的Dockerfile:

My Dockerfile:

FROM java:8

# Install maven
RUN apt-get update
RUN apt-get -y install maven

# Build foo
ENV curr /foo
WORKDIR $curr
ADD $curr/pom.xml /code/$curr
ADD $curr/src /code/$curr
RUN mvn package

当我尝试构建它与docker构建。

When I try to build it with "docker build .":

...
Step 7 : ADD $curr/src /code/$curr
Error processing tar file(exit status 1): Error setting up pivot dir: mkdir /var/lib/docker/devicemapper/mnt/236c9a1ac7edbd177f4718286f530cbba4ca275ec881be1e8fa3168e572843ac/rootfs/code/foo/.pivot_root774820419: not a directory

根据我的理解,当mkdir尝试创建一个目录时,打印出这个文件,但是一个文件,符号链接或套接字相同的名称已经存在。但是这似乎是Docker内部的一些步骤,改变调试级别并没有产生任何有用的输出。

From what I understand, mkdir prints this when it tries to create a directory, but a file, symlink or socket by the same name already exists. But this seems to be some step internal to Docker, and changing the debug level didn't produce any useful output.

你在 / foo 中忘记了一个 / 。在您的配置中,docker将把您的 pom.xml 作为 / code / foo 而不是,我猜你打算, /code/foo/pom.xml 。然后尝试将您的源添加到您的pom.xml文件中,从而导致此错误。

You forgot a / in /foo. In your configuration docker will put your pom.xml as /code/foo rather than, what I guess you intended, /code/foo/pom.xml. It then tries to add your source to your 'pom.xml' file which gives this error.

尝试:

FROM java:8

# Install maven
RUN apt-get update
RUN apt-get -y install maven

# Build foo
ENV curr /foo/ # <-- missing /
WORKDIR $curr
ADD $curr/pom.xml /code/$curr
ADD $curr/src /code/$curr
RUN mvn package