'on building docker image level=error msg="Can't close tar writer: io: read/write on closed pipe"

time="2017-10-27T07:39:20Z" level=error msg="Can't add file /var/app/current/app/content_classifier/forest.pickle to tar: io: read/write on closed pipe" 
time="2017-10-27T07:39:20Z" level=error msg="Can't close tar writer: io: read/write on closed pipe"
Failed to build Docker image aws_beanstalk/staging-app:  tar writer: io: read/write on closed pipe" 
Error response from daemon: Untar error on re-exec cmd: fork/exec /proc/self/exe: cannot allocate memory. Check snapshot logs for details. (Executor::NonZeroExitStatus)

I have a Pickle object in django_app/content_classifer object. There is a class to predict the result and it's initializing itself when celery tasks file gets initialised.

docker build keeps failing after giving an error message as in the title.



Solution 1:[1]

The problem faced because the process that generates the pickle object has a diffrent user assigned then process that was accessing the pickle object.

I define the location for pickle object in the setting file.

picklefile = "usr/local/webapp/forest.pickle"

I simply added the step as following in Dockerfile.

RUN chown -R /user/local/webapp/ 

Solution 2:[2]

if you are on Mac, make sure docker hub is running

Solution 3:[3]

I had same issue few minutes ago, when I found your issue :) I had some files opened = they were used by another application(GIT)

Please make sure that no files are being used.

Hope it will help.

Solution 4:[4]

I had this problem in Ubuntu and sudo service docker restart fixed it

Solution 5:[5]

I had the same problem. If you are using Docker on Windows using Docker Toolbox you should first run the Docker Quickstart Terminal, otherwise, it will not work. Hope this helps someone!

Solution 6:[6]

It seems that this is an Input/Output error and the docker couldn't access the files it wants to. As suggested by @Luk3rson make sure that the files are not used by any other application. Try to debug the logs in /var/log/. May it help you.

Solution 7:[7]

I had a similar error when I was using a Docker context for a remote Docker host. After reverting to the Docker daemon on my local machine (Linux) everything worked again.

Solution 8:[8]

For me when I was running it with WSL 2, I just had to add sudo to the docker command and it was all good.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 rezan21
Solution 3 Luk3rson
Solution 4 benhsu
Solution 5 Oscar2av
Solution 6 Rushal Verma
Solution 7 Matthew Setter
Solution 8 Tina J