Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: Error processing tar file(exit status 1): Error setting up pivot dir: not a directory

Tags:

linux

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!

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.

like image 354
A. Wilder Avatar asked Dec 06 '25 16:12

A. Wilder


1 Answers

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
like image 140
Philiiiiiipp Avatar answered Dec 08 '25 15:12

Philiiiiiipp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!