> 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/clore.ai/clore.ai-eng-es/para-hosts/server-offline-on-clore.ai/docker-disk-space-cleanup.md).

# Limpieza del espacio en disco de Docker

## Limpieza de espacio en disco de Docker (hosts)

Los datos de Docker crecen con el tiempo en las máquinas host.\
Los alquileres antiguos dejan contenedores detenidos, imágenes sin usar, volúmenes y caché de compilación.\
Si no lo limpias, el disco raíz se llena y las implementaciones empiezan a fallar.

{% hint style="info" %}
Ejecuta la limpieza solo cuando el servidor esté **no esté alquilado** y no necesites datos antiguos de contenedores.\
Si no estás seguro, detente aquí y haz primero una comprobación del uso del disco.
{% endhint %}

***

## 1) Comprueba el uso del disco

### Espacio en disco a nivel del SO (`df -h`)

Esto muestra el espacio libre en cada sistema de archivos montado.

```bash
df -h
```

Lo que más te importa es `/` (raíz) y la partición que contiene `/var/lib/docker`.

### Uso de disco a nivel de Docker (`docker system df`)

Esto muestra qué está almacenando Docker y cuánto se puede recuperar.

```bash
docker system df
```

Si quieres más detalle por imagen/contenedor:

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

***

## 2) Limpieza completa (recomendada)

Este es el comando para “reiniciar los restos de Docker de alquileres anteriores”.\
Elimina contenedores, imágenes, redes y **volúmenes sin usar**.

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

{% hint style="warning" %}
`-a` elimina **todas las imágenes sin usar**, no solo las “colgantes”.\
Eso incluye imágenes en caché que podrías querer para implementaciones futuras más rápidas.
{% endhint %}

***

## 3) Comandos de limpieza individuales (más control)

Úsalos cuando quieras limpiar una categoría específica.\
Son más seguros para el mantenimiento incremental.

### Contenedores (solo detenidos)

```bash
docker container prune
```

### Imágenes (sin usar)

Eliminar solo capas colgantes:

```bash
docker image prune
```

Eliminar todas las imágenes sin usar (mismo riesgo que `system prune -a`):

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

### Volúmenes (sin usar)

```bash
docker volume prune
```

### Redes (sin usar)

```bash
docker network prune
```

***

## 4) Buenas prácticas para el mantenimiento del host

1. Limpia **entre alquileres** o durante un tiempo de inactividad planificado.
2. Mantén un margen de seguridad.\
   Apunta a **10–20 GB** libres en el disco raíz en todo momento.
3. Comprueba regularmente el uso de Docker:
   * `df -h`
   * `docker system df`
4. Prefiere primero la limpieza incremental:
   * `docker container prune`
   * `docker image prune`
   * `docker volume prune`
5. Usa la limpieza completa solo cuando sea necesario:
   * `docker system prune -a --volumes`
6. Si el uso del disco sigue creciendo rápido, investiga:
   * Volúmenes grandes creados por los inquilinos.
   * Registros en `/var/lib/docker/containers/*/*.log`.
   * Caché de compilación de reconstrucciones frecuentes de imágenes.


---

# 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/clore.ai/clore.ai-eng-es/para-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.
