0 0 Share PDF

How to free space when space is no longer available and results in an error no space left on device

Issue

The Docker daemon requires adequate space to write to /var/lib/docker before it can start/restart successfully. If the daemon is unable to start due to a "No space left on device" error, the following process can be used to remove large container log files to free disk space.

Resolution

To successfully remove large container log files, to clear space for the Docker daemon, use these steps:

  1. Sort the /var/lib/docker/containers directory to show which container directories have the largest log files:

    $ du -d1 -h /var/lib/docker/containers | sort -h
    

    The output of this command lists the container directories, regarding container log size, in ascending order.

  2. Clear the contents of the container log file that you choose:

    $ cat /dev/null > /var/lib/docker/containers/container_id/container_log_name
    

    This command results in a zero size log file.