Loading...

How to fix Docker "no space left on device"

Jonas Scholz
3 min read 26. Jan. 2025

When you're working with Docker and suddenly see the "no space left on device" error, it can be frustrating. But don't worry, it's a common issue and there are several steps you can take to fix it. Let's walk through the process together.

First, you need to figure out where the space issue is coming from. Docker uses a few different places on your system for storage, so you'll want to check each of these:

  1. Docker Images and Containers: Over time, you might have accumulated a lot of Docker images and containers that you're not using anymore. These can take up a lot of space.
    To see how much space your Docker images and containers are using, you can run this command in your terminal:
    docker system df
    

    This will show you a summary of your Docker disk usage. If you see that images and containers are taking up a lot of space, you can clean them up with:
    docker system prune
    

    This command will remove all stopped containers, unused networks, dangling images, and build cache. It's a good way to free up space, but be careful because it will delete things you might want to keep, so make sure you're okay with that before running it.
  2. Docker Volumes: Docker volumes are another place where space can be used up. Volumes are used to store data that your containers need, and sometimes they can grow quite large.
    To see how much space your volumes are using, run:
    docker volume ls -qf dangling=true
    

    This will show you any volumes that aren't being used by any containers. If you see volumes listed here, you can remove them with:
    docker volume rm $(docker volume ls -qf dangling=true)
    

    This will delete all the volumes that aren't being used, which can help free up space.
  3. Docker Root Dir: Docker stores its data in a directory on your system, usually /var/lib/docker. If this directory gets too full, you'll see the "no space left on device" error.
    To check how much space is being used in this directory, you can use the du command:
    sudo du -sh /var/lib/docker
    

    If you see that this directory is using a lot of space, you might need to move it to a different location with more space. You can do this by changing the docker-root option in your Docker daemon configuration file.
    To do this, you'll need to edit the Docker daemon configuration file, usually found at /etc/docker/daemon.json. If the file doesn't exist, you can create it. Add or modify the data-root option to point to a new directory:
    {
      "data-root": "/path/to/new/docker/directory"
    }
    

    After making this change, you'll need to restart the Docker service for it to take effect:
    sudo systemctl restart docker
    
  4. Host System: Sometimes, the issue isn't with Docker itself, but with the host system running out of space. If you've checked all the Docker-related places and still see the error, you should check your host system's disk usage.
    You can do this with:
    df -h
    

    This will show you how much space is being used on your system. If you see that your system is running low on space, you'll need to free up space by deleting files or expanding your disk.

By following these steps, you should be able to figure out where the space issue is coming from and fix the "no space left on device" error in Docker. Remember to be careful when deleting things, and always make sure you have backups of any important data before making changes.

Welcome to the container cloud

Sliplane makes it simple to deploy containers in the cloud and scale up as you grow. Try it now and get started in minutes!