Build Failed - Tar returned a non-zero code: 2 & Directory renamed before its status could be extracted

My Dockerfile looks as follows…

FROM node:0.10.46

RUN (apt-get update -y)
RUN (apt-get install -y curl bzip2)
RUN (npm install forever -g)

COPY build /build

WORKDIR /build

RUN (tar xzf *.tar.gz > /dev/null)
RUN (ls /build)

WORKDIR /build/bundle/programs/server
RUN (npm install)
WORKDIR /build/bundle
#COPY /build/package.json /build/bundle/package.json

#Create New Package Json
COPY src/myApp/package.json /temp/package.json

#Get Settings.json
COPY src/myApp/settings.json /build/bundle/settings.json

WORKDIR /build
RUN (npm install jsonfile)
RUN (node create_package.js)

#Clear up
RUN (rm /temp/package.json)
RUN (rm -rf /build/node_modules)
RUN (rm /build/create_package.js) 
RUN (rm /build/myApp.tar.gz)

#Expose ports (From PORT env variable)
EXPOSE 8080

#Install & Execute application
WORKDIR /build/bundle
RUN (npm install)
CMD [ "npm", "start"]

It has been working fine deploying as i would expect.
The only thing that gets updated is the tar file (package of all the code).

Recently i’m getting this error

Build failed: The command ‘/bin/sh -c (tar xzf *.tar.gz > /dev/null)’ returned a non-zero code: 2

Then when I look at the logs I get loads of these…

Directory renamed before its status could be extracted

Then the output of

tar: Exiting with failure status due to previous errors
e[0m Removing intermediate container 6c73d913d7c1
The command ‘/bin/sh -c (tar xzf *.tar.gz > /dev/null)’ returned a non-zero code: 2

The line it is failing on in the Dockerfile is

RUN (tar xzf *.tar.gz > /dev/null)

I have looked on multiple forums and can’t find anything. Strangely I am packaging it with Meteor Build, it seems other are having this issue also.

However, when i run it locally it builds fine… Also the same on my Ubuntu server…

Any help would be much appreciated, please let me know if you need additional logs to help debug.

Many thanks!

Further information…

After 5 builds (Of the exact same codebase), the builds run successfully.

Why does it fail on some :confused: