Docker Full disk: Real occupancy is recognized before cleanup

What will this help you do?

A safe, step-by-step. Docker Disk takes the diagnostic guide. Learn how to distinguish mirrors, layers, volumes, and logs to prevent data loss during clean-up.

Who is it for?

Readers working through this problem and checking each step.

Before you start

Check the scope of this guide, then prepare the environment and materials it actually calls for.

On this page

When the production server reports that the disk is full, the most immediate impulse is to run a radical clean-up order. However, blind execution. docker system prune This guide focuses on measuring actual usage before any disruptive operation is undertaken, ensuring that real-time data are retained while recycling space.

I understand. Docker Storage Component

Docker Storage is not a single entity, but consists of several separate components that consume disk space in different ways.Volumes) is the permanent data storage of containers by Docker Creates and manages. They are stored in Docker The directory on the mainframe is isolated from the core function of the mainframe. This isolation makes it the ideal option for the sustainable container to generate data, but it also means that standard file system commands may not be as clear as conventional files.Source:Docker Volume Document

By contrast, mirrors and layers are read-only templates. Build caches in docker build . The log is a text file that accumulates over time. Understanding these differences is essential because the clean-up strategy for each component varies widely. For example, if a container does not use a mirror, it is usually safe to delete it; if the volume contains a database record or a user upload, removing it may result in the loss of permanent data.

Step 1: Use docker system df Identification of source of occupancy

The first step in any disk space survey is to obtain a high-level overview of space use.docker system df The order provides a summary of mirrors, containers, rolls and disk usage for the construction of caches.

bash
docker system df

This command will produce a table showing the total size and recoverable size of each category. Please pay close attention to "RECLAIMABLE column. If Build Cache"or"Images. The bulk of the space is marked as recyclable, so you can safely continue to trim these particular areas. However, if Volumes. The volume usually contains key application data.

Step 2: Analysis of mirror and layer usage

If... docker system df Output indicates that the mirror takes a lot of space. You need to identify which mirrors are not used. You can use the following command to list all mirrors and their sizes:

bash
docker images

_Other Organiser <none> . You can also check the mirror that is not associated with any running or stopped container. Before deleting any mirror, verify that it is not defined by any service or required to deploy a script. Deleting a mirror that is still referenced in the container will cause the container to fail when restarting.

Step three: use of safe survey files

Volumes are the most dangerous clean-up components because they store persistent data, as is the case. Docker Volume Document As mentioned, the volume is sustainable. Docker Recommended mechanisms for data generated and used by containers. Volumes are easier to back up or migrate than bound mounts and can be used Docker CLI The order is administered.

To identify which volumes are in use, run:

bash
docker volume ls

This lists all volumes. To see which containers are in use, you can check the containers or use them:

bash
docker volume inspect <volume_name>

If the volume is not in use, delete it may be safe, but only if you are sure that the data contained therein is no longer needed. For the production environment, it is strongly recommended that the contents of the volume be backed up before it is deleted. This can be done by creating a temporary container to load the volume and copy the data to a secure location.

Step 4: Check the container log

The container log may increase indefinitely if there is no rotation or interruption. By default,Docker Store logs in /var/lib/docker/containers/<container_id>/ . If you have many containers, these log files may consume a lot of disk space.

You can use the following command to check the size of the log file:

bash
du -sh /var/lib/docker/containers/*/*-json.log

If the log files are large, you can cut them without stopping the container:

bash
truncate -s 0 /var/lib/docker/containers/<container_id>/<container_id>-json.log

In order to prevent this problem in the future, please Docker Dæmon Configuration (Pilot)/etc/docker/daemon.json) configuring log rotation, is json-file Log Driver Settings max-size and max-file option.

Step 5: Execute test run and verify

Before executing any cleanup command, perform a trial run to see what is to be deleted. For example, to view docker image prune Which mirrors will be deleted, you can use:

bash
docker image prune --filter "until=24h"

The command will list the mirrors that will be removed, without actually deleting them. Review the list carefully to ensure that the key mirrors are not included. Once you are sure that cleaning is safe, you can execute the command without a test running sign.

Check the container's state and make sure that they can access its volumes and logs.

Risk and retreat strategy

Docker The main risk of disk clean-up is data loss, especially from the scrolls. To mitigate this risk, key data is always backed up before being deleted. If you accidentally delete the scroll, you can try to restore it from the backup. If there is no backup, the data is probably lost. For mirrors, the risk is lower because they can be retrieved from the register. But if you have a custom mirror that is not in the register, you should export it to the user before deleting it. tar Documentation.

If the cleanup order causes the service to be interrupted, the first step is to identify which component has been removed. If the mirror is removed, then pull it back. If the volume is deleted, restore it from the backup. If the log is cut, they automatically recreate. After the cleanup, disk usage is monitored to ensure that the space is recovered and no new problems arise.

Volume Storage Authentication

Please confirm how the data are managed for sustainability before implementing a radical clean-up order. Docker Volumes Document, the volume is the preferred mechanism for durating the data, stored in a dedicated directory on the host, separated from the core packaging layer. Since the standard clean-up order does not automatically delete the volume unless it is marked in a visible form, the distribution of the volume is checked to prevent accidental data loss.

Sources of information

Next steps

Continue with the next useful task; you do not need to read everything at once.

  1. Deploy Open WebUI with Docker and Persistent Storage →
  2. Install Ollama on Linux and Expose It Safely →
  3. Ollama vs Open WebUI: Different Roles in a Self-hosted AI Stack →
RESOURCES I USE · REFERRAL

Two services to compare when you are ready to launch

This is not an automated ranking, and neither service is necessary for everyone. These are services I use, with the use case and limitations kept visible.

Cloud server · Used for early projects

RainYun

A practical candidate for a website or small service. Choose by user region, configuration and measured workload rather than the lowest headline price.

Referral disclosure: these links contain my referral information. I may receive a platform benefit if you sign up or order, at no additional charge from AIOOS. Check the order page for current pricing, availability, regions and terms. Read the full affiliate disclosure