Docker: Error processing tar file(exit status

2019-07-20 05:13发布

问题:

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!

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

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

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.

回答1:

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.

Try:

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


标签: linux docker