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.

Updated

On this page

When a production server runs out of disk space, first measure actual usage. Do not run blanket Docker cleanup commands without reviewing the affected resources, business purpose, backups and rollback dependencies. This guide provides read-only investigation, not automatic deletion instructions.

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. An image without a current container reference may still be required for rollback; 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. RECLAIMABLE describes Docker reference accounting, not business permission to delete. Review rollback dependencies and rebuild cost before considering cleanup. 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. Docker normally refuses to remove referenced images. Unreferenced rollback images still need protection; never bypass safeguards with force flags.

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. The following reads volume metadata, not a complete list of containers referencing it:

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: Inspect the actual logging driver

Read the container metadata; do not assume json-file or a fixed Docker data directory:

bash
docker inspect --format '{{.HostConfig.LogConfig.Type}} {{.LogPath}}' <container_name>

Do not externally truncate, delete or edit Docker-managed json-file logs. Docker warns that these files are exclusively managed by its daemon; external manipulation can interfere with logging. Lost historical logs do not regenerate.

Use the official json-file rotation documentation to plan max-size and max-file settings. Back up logs and configuration, test in isolation, and arrange a maintenance window. Changed daemon defaults apply only to newly created containers; existing containers need controlled recreation through the application's deployment procedure. Do not restart every service merely to recover disk space.

Step 5: Read-only inventory, then explicit deletion approval

Docker image prune is not a dry-run. The until filter selects images by creation time; confirming the command performs deletion. There is no dry-run option, and the confirmation prompt is not an exact inventory of selected images.

Start with read-only commands:

bash
docker system df -v
docker image ls --filter dangling=true
docker ps -a
docker ps -a --filter volume=<volume_name>

These inventories help identify references, but do not guarantee an exact preview for every prune filter. Record each candidate's purpose, backup and rollback dependency. Retain anything whose purpose is uncertain. This guide deliberately provides no executable deletion command. After explicit approval, use a separately verified maintenance procedure and check every application, retained dataset, rollback image and disk measurement. See image prune.

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. Truncated historical logs cannot be recovered from new log entries; retain a verified backup. 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

Safety clarification: default system prune does not remove volumes. Unreferenced does not mean disposable; deleted data requires a verified backup to recover.

Did this guide solve your problem?

Tell us which step blocked you, your version and what happened. Your feedback goes to the editorial queue.

Send feedback or share your experience →

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. Host Multiple Websites on One Server with Caddy →
  3. Install Ollama on Linux and Expose It Safely →
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