> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/for-hosts/server-offline-on-clore.ai/docker-disk-space-cleanup.md).

# Docker Disk Space Cleanup

## Docker Disk Space Cleanup (Hosts)

Docker data grows over time on host machines.\
Old rentals leave behind stopped containers, unused images, volumes, and build cache.\
If you don’t clean it up, the root disk fills up and deployments start failing.

{% hint style="info" %}
Run cleanup only when the server is **not rented** and you don’t need any old container data.\
If you’re unsure, stop here and do a disk usage check first.
{% endhint %}

***

## 1) Check disk usage

### OS-level disk space (`df -h`)

This shows free space on each mounted filesystem.

```bash
df -h
```

You care mainly about `/` (root) and the partition that holds `/var/lib/docker`.

### Docker-level disk usage (`docker system df`)

This shows what Docker is storing and how much is reclaimable.

```bash
docker system df
```

If you want more detail per image/container:

```bash
docker system df -v
```

***

## 2) Complete cleanup (recommended)

This is the “reset Docker leftovers from previous rentals” command.\
It removes unused containers, images, networks, and **unused volumes**.

```bash
docker system prune -a --volumes
```

{% hint style="warning" %}
`-a` removes **all unused images**, not just “dangling” ones.\
That includes cached images you might want for faster future deployments.
{% endhint %}

***

## 3) Individual cleanup commands (more control)

Use these when you want to clean a specific category.\
They’re safer for incremental maintenance.

### Containers (stopped only)

```bash
docker container prune
```

### Images (unused)

Remove dangling layers only:

```bash
docker image prune
```

Remove all unused images (same risk as `system prune -a`):

```bash
docker image prune -a
```

### Volumes (unused)

```bash
docker volume prune
```

### Networks (unused)

```bash
docker network prune
```

***

## 4) Best practices for host maintenance

1. Clean up **between rentals** or during planned downtime.
2. Keep a safety buffer.\
   Aim for **10–20 GB** free on the root disk at all times.
3. Check Docker usage regularly:
   * `df -h`
   * `docker system df`
4. Prefer incremental cleanup first:
   * `docker container prune`
   * `docker image prune`
   * `docker volume prune`
5. Use full cleanup only when needed:
   * `docker system prune -a --volumes`
6. If disk usage keeps growing fast, investigate:
   * Large volumes created by renters.
   * Logs under `/var/lib/docker/containers/*/*.log`.
   * Build cache from frequent image rebuilds.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.clore.ai/for-hosts/server-offline-on-clore.ai/docker-disk-space-cleanup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
