添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I needed space and executed: docker rmi $(docker images -f "dangling=true" -q)

Since then I can't with docker-compose: docker-compose build , I get the error: ERROR: Error processing tar file(exit status 1): unexpected EOF .

I tried to remove all images, reinstall docker, but nothing will do: always the same error, after quite some time.

I built on another system and it worked, which suggests that this is a wrong-state issue.

Any idea what I should clean?

Using:

▶ docker version
Client:
 Version:      17.03.0-ce
 API version:  1.24 (downgraded from 1.26)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:01:32 2017
 OS/Arch:      linux/amd64
Server:
 Version:      1.12.6
 API version:  1.24 (minimum version )
 Go version:   go1.6.2
 Git commit:   78d1802
 Built:        Tue Jan 31 23:35:14 2017
 OS/Arch:      linux/amd64
 Experimental: false
▶ docker-compose version
docker-compose version 1.11.2, build dfed245
docker-py version: 2.1.0
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t  3 May 2016
                have you tried removing /var/lib/docker directory completely before reinstalling? CAUTION: this willl remove all volumes,containers,images... make sure you back it up first.
– Farhad Farahi
                Mar 14, 2017 at 12:11
                I had this issue when my build directory contained several gigabytes core dump file. I've tried removing docker directory with no luck, but then simply removing core file fixed the problem.
– Andrew Kravchuk
                Oct 17, 2017 at 9:58
                @dondublon doesn't matter. depends on what you have among the files docker is trying to build with. just chown -R your project folder to the user it's supposed to have. In my case, one of my containers wrote a file which was root owned and had no read permission for anyone except for owner
– Oktav
                Sep 15, 2017 at 9:25
                When I was looking for an answer, I ignored yours because thought that there is nothing to do with permissions in my case. I was wrong. In one folder I had a file marked as "crashed data". This file was likely generated by docker container and it didn't have access permissions. So guys don't repeat my mistake, check all your project folders carefully.
– Desprit
                Oct 23, 2017 at 20:14
                This was the answer for me. A previous docker run had left a bash_history file owned by root in the project folder.
– Routhinator
                Dec 11, 2017 at 17:10
  • Backup /var/lib/docker then:

  • Remove /var/lib/docker Caution: This will remove images, containers, volumes, ... make sure you back it up first.

    rm -rf /var/lib/docker
    
  • Start Docker service

    systemctl start docker  
    

    Update:

    As noted in the other answer, In somecases it might be file permissions issue. Please review permissions.

    You're good! :) How does backing it up helps me since I'll have to rebuild anyway, right? It's fine because it is my development machine. – Augustin Riedinger Mar 15, 2017 at 8:56 Usually ppl have lots of images and containers with volumes, and after a couple of days they remember data is missing, so I always encourage for backing up. – Farhad Farahi Mar 15, 2017 at 10:14 Gotcha. But if I want to restore my images, I simply need to restore /var/lib/docker/image and it will work out-of-the-box? – Augustin Riedinger Mar 15, 2017 at 10:56

    For me it was a permission error. I walked against the same exact issue as PR, ERROR: Error processing tar file(exit status 1): unexpected EOF My solution is dirty but worked for me

    chown -R 777 /foo/bar/project

    You almost always want to avoid to set permissions on 777, 655 is more reasonable.

    0 = ---
    1 = --x
    2 = -w-
    3 = -wx
    4 = r-
    5 = r-x
    6 = rw-
    7 = rwx
    

    A more detailed explanation can be found here: https://www.pluralsight.com/blog/it-ops/linux-file-permissions

    Solving this error for good

    docker build needs read access to every file in the context directory tree. To avoid permission issues, add all your mounted directories to .dockerignore file except those required for the build. For example, for this docker-compose file:

    version: '3'
    services:
        myservice:
            build: .
        volumes:
            - './etc:/etc/myservice'
            - './log:/var/log/myservice'
    

    Add a .dockerignore file with this content:

    The problem will go away no matter the permissions of the files in your mounted directories.

    How to get a more informative error

    The docker-compose error is not very informative so you can try to run docker on each build just to get detailed information:

    $ docker build .
    

    You will get an error like this:

    error checking context: 'no permission to read from '/home/david/docker/myservice/log/2020161.log'.
    

    For me the issue turned out that a Docker Pull was hung, so I CTRL+C'd out of it and tried again. Same error message.

    In the end I found some files owned by root in this directory. Giving the files proper permissions fixed the issue.

    chown -R <username>:<group> /var/lib/docker/tmp

  • MAC Docker version 17.12.0-ce, build c97c6d6
  • there could be several different problems. You can find out the problem by checking the issue that docker build is throwing.

    The problem is that docker-compose build will suppress the information of the issue. To find out what the issue is

    do not use:

    docker-compose build XXX
    

    instead, open your docker-compose.yml, find the build: tag of the service is giving you an issue, e.g.

    services:
       yourservice: 
           build: yourservice-directory/
    

    and then run:

    docker build yourservice-directory
    

    after this you will see what is the issue.

    I did docker build --file <dockerfile> . and got this error: error checking context: 'no permission to read from '/<my repo>/core.19168''.. I deleted those files and it worked! Thanks! – Diego M.F. Jul 31, 2020 at 21:44

    Reference: https://medium.com/the-code-review/clean-out-your-docker-images-containers-and-volumes-with-single-commands-b8e38253c271

    1. Clean up containers, images, volumes and networks on your system:
    docker system prune --all --force --volumes
    2. docker-compose up

    If you have tried looking through permissions, docker reset, docker system prune, deleting all containers, deleting all images (dangling or otherwise), reading about everything that there is surrounding this issue and have had no success. Try uninstalling docker and re-installing the stable version.

    Although, the error I was struggling with was : Error processing tar file(exit status 1): mkdir /some/path/name: no such file or directory

    I did all the above mentioned solution and nothing worked for me, and lastly I tried upgrading docker packages and it worked for me. – Khalid Waseem Oct 23, 2020 at 19:52

    In my case, the problem was a .dump file created by one of my project's scripts.

    docker-compose passes the context to the engine as a tar file, therefore, the build command was packing a tar (the .dump file) inside another tar file (the docker context) hence throwing an unexpected EOF on the context.

    Since I don't need the .dump file in the container, I added it to my .dockerignore file.

    I was having the same issue when i changed the Dockerfile location in a python project. I tried the accepted answer and didn't work for me.

    I resolved the problem by running :

    find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs sudo rm -r
    

    On the project root.

    The problem was that docker-compose build was trying to read files inside pycache folders.

    Maybe this also can be fixed with a proper use of .dockerignore but i dind't try it

    Hope this helps.

    Saludos.

    Try increasing the memory for Docker, it fixed the issue for me.

    Docker memory setting in Preferences was set to 2GB, so when pulling the ~3GB image, I was getting exactly this error:

    $ docker pull skymindops/skil-ce
    latest: Pulling from skymindops/skil-ce
    118c5f2883d6: Pull complete 
    3d199b2e6224: Extracting [==================================================>]  2.902GB/2.902GB
    failed to register layer: Error processing tar file(exit status 1): unexpected EOF
    

    Increasing the memory limit fixed it (I also increased the swap, but unsure was it required or not).

    My question is totally irrelevant with the asked question, but how did you specify the memory limit for docker? you mentioned that Docker memory setting in Preferences was set to 2GB where did you specify the Preference? I want to set the memory limit to the docker deamon actually. – Yudi Sep 28, 2018 at 9:48

    I tried everything from rebooting, reinstalling Docker, and purging /var/lib/docker.

    My cause was something corrupting the build context in my project. After I ran git clean to reset the project directory back to its original state, I was able to docker-compose.

    Run git clean -iXd in your project's root to interactively git clean.

    Edit: after a while, it happened again. This time, git clean didn't fix it. I'm pretty sure it only happens on Ubuntu. My arch coworkers have never encountered it.

  • Ensure specify the image name on docker-compose.yml for example, specify the image name and container_name as django_practice_db/django_practice_web

    services:
      django_practice_db:
        image: postgres
        container_name: django_practice_db
      django_practice_web:
        container_name: django_practice_web
        build: .
        command: pipenv run python manage.py runserver 0.0.0.0:8000
    
  • Copy the project file to another place

  • Go inside the copied project directory

  • Execute docker-compose build

  • Go back to the original project directory

  • Execute docker-compose up

    Not sure why I can build images when I change the folder path.

    Another potential cause of this, especially if you're seeing an error like

    Error processing tar file(exit status 1): write /code/node_modules/xxx: no space left on device
    

    You might want to check the "disk image size" in the Docker application. You might need to increase the disk size.

    I had the same error in Ubuntu: Ran below command and it worked (just make sure to start again once you are done):

    /opt/McAfee/ens/tp/init/mfetpd-control.sh stop
    

    Solve for me. You need have your user in docker group (usermod -aG docker $USER):

    sudo chmod -R 775 . sudo chown -R : .

    This question is a little bit old now, but I had this problem today and what I figured out was next. When I was exporting my image as a tar file with next command:

    docker save -o exportedfile.tar myimage/version:latest
    

    I exported this in Linux shell instead of CMD. When I do it in CMD everything works fine. I guess there is some difference in -o flag between Windows and Linux.

    I had the same issue as OP, but neither the approved answer nor the top voted answer did it for me.

    What pointed me in the right direction was a comment under the approved answer by JGlass saying that after closing Notepad++ everything worked properly.

    I wasn't using Notepad++, but I did have Visual Studio open. I didn't have any files open either, but I did have the project open in the solution explorer. After closing Visual Studio, the issue was resolved.

    In my case it wasn't a permission issue, but Docker was unable to access the file because another application was using it.

    Hopes this helps someone.

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •