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:

hey it’s been 8 years - hope Docker has been treating you well :slight_smile:

did you ever get to the bottom of this?

I have similar errors on a build but in my case, it’s running in a Ubuntu 22.04 container emulated by Rosetta. I get the “Directory renamed” & also random rsync errors (the commands work fine inside the Docker shell)

Ubuntu build container works with fine on an x86 MBP2015.

I’m currently chaulking this up to low level file operations not being translated by Rosetta with 100% fidelity (esp at the rate of an automated build? perhaps a bug in translating buffer logic?)

If I could get gcc-multilib installed in an arm64 Ubuntu container for cross compiling, this would eliminate the Rosetta requirement!

update on this front: I got an Ubuntu arm64 build container up (thus eliminating Rosetta as the cause) and it still has random rsync errors so this is something specific to the Docker Desktop for Mac implementation - sometimes the containers even crash during heavy builds.

Ive since pulled up Ubuntu arm64 in VMWare Fusion and got the entire build to the end (almost but for purposes of this conversation, it built the final distribution image without any random rsync errors)

A bit bummed I lose Dockerfiles and bind mounts but if Docker Desktop is going to be half-baked on the Mac, I’ll have to pass.