Docker error : no space left on device

后端 未结 25 2762
悲哀的现实
悲哀的现实 2020-11-28 00:01

I installed docker on a Debian 7 machine in the following way

$ echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
$          


        
相关标签:
25条回答
  • 2020-11-28 00:46

    Don't just run the docker prune command. It will delete all the docker networks, containers, and images. So you might end up losing the important data as well.

    The error shows that "No space left on device" so we just need to free up some space.

    The easiest way to free some space is to remove dangling images.

    When the old created images are not being used those images are referred to as dangling images or there are some cache images as well which you can remove.

    Use the below commands. To list all dangling images image id.

    docker images -f "dangling=true" -q
    

    to remove the images by image id.

    docker rmi IMAGE_ID
    

    This way you can free up some space and start hacking with docker again :)

    0 讨论(0)
  • 2020-11-28 00:50

    I had the same error and solve it this way:

    1 . Delete the orphaned volumes in Docker, you can use the built-in docker volume command. The built-in command also deletes any directory in /var/lib/docker/volumes that is not a volume so make sure you didn't put anything in there you want to save.

    Warning be very careful with this if you have some data you want to keep

    Cleanup:

    $ docker volume rm $(docker volume ls -qf dangling=true)
    

    Additional commands:

    List dangling volumes:

    $ docker volume ls -qf dangling=true
    

    List all volumes:

    $ docker volume ls
    

    2 . Also consider removing all the unused Images.

    First get rid of the <none> images (those are sometimes generated while building an image and if for any reason the image building was interrupted, they stay there).

    here's a nice script I use to remove them

    docker rmi $(docker images | grep '^<none>' | awk '{print $3}')
    

    Then if you are using Docker Compose to build Images locally for every project. You will end up with a lot of images usually named like your folder (example if your project folder named Hello, you will find images name Hello_blablabla). so also consider removing all these images

    you can edit the above script to remove them or remove them manually with

    docker rmi {image-name}

    0 讨论(0)
  • 2020-11-28 00:50

    Docker leaves dangling images around that can take up your space. To clean up after Docker, run the following:

    docker image prune [-af if you want to force remove all images]
    

    or with older versions of Docker:

    docker rm $(docker ps -q -f 'status=exited')
    docker rmi $(docker images -q -f "dangling=true")
    

    This will remove exited and dangling images, which hopefully clears out device space.

    0 讨论(0)
  • 2020-11-28 00:50

    Seems like there are a few ways this can occur. The issue I had was that the docker disk image had hit its maximum size (Docker Whale -> Preferences -> Disk if you want to view what size that is in OSX).

    I upped the limit and and was good to go. I'm sure cleaning up unused images would work as well.

    0 讨论(0)
  • 2020-11-28 00:52

    I also encountered this issue on RHEL machine. I did not find any apt solution anywhere on stack-overflow and docker-hub community. If you are facing this issue even after below command:

    docker system prune --all

    The solution which worked finally:

    1. docker info
      • To check current docker storage driver
      • Mine was : Storage Driver: devicemapper; If you have storage driver as overlay2 nothing to worry about. Solution will still work for you.
    2. df -h
      • This is to check the available file systems on machine and the path where they are mounted. Two mounted path to have a note:
      • /dev/mapper/rootvg-var 7.6G 1.2G 6.1G 16% /var
      • /dev/mapper/rootvg-apps 60G 9.2G 48G 17% /apps
      • Note- By default docker storage path is /var/lib/docker. It has available space ~6 GB and hence all the space related issues. So basically, I have to move default storage to some other storage where available space is more. For me its File sysyem path '/dev/mapper/rootvg-apps' which is mounted on /apps. Now task is to move /var/lib/docker to something like /apps/newdocker/docker.
    3. mkdir /apps/newdocker/docker
    4. chmod -R 777 /apps/newdocker/docker
    5. Update docker.serive file on linux which resides under: /usr/lib/systemd/system
      • vi /usr/lib/systemd/system/docker.service
    6. if storage device is devicemapper , comment existing ExecStart line and add below under [Service]:
      • ExecStart=
      • ExecStart=/usr/bin/dockerd -s devicemapper --storage-opt dm.fs=xfs --storage-opt dm.basesize=40GB -g /apps/newdocker/docker --exec-opt native.cgroupdriver=cgroupfs
    7. Or if storage device is overlay2:
      • just add -g /apps/newdocker/docker in the existing ExexStart statement.
      • Something like ExecStart=/usr/bin/dockerd -g /apps/newdocker/docker -H fd:// --containerd=/run/containerd/containerd.sock
    8. rm -rf /var/lib/docker (It will delete all existing docker data)
    9. systemctl stop docker
    10. ps aux | grep -i docker | grep -v grep
      • If no output has been produced by the above command, reload systemd daemon by below command.
    11. systemctl daemon-reload
    12. systemctl start docker
    13. docker info
      • Check out the Data Space Available: 62.15GB after mouting to docker to new File system.
    14. DONE
    0 讨论(0)
  • 2020-11-28 00:52

    you can also use:

    docker system prune
    

    or for just volumes:

    docker volume prune
    
    0 讨论(0)
提交回复
热议问题