# Reducing Docker directory size

**URL:** https://forum.yunohost.org/t/reducing-docker-directory-size/22822
**Category:** Support apps
**Tags:** gitlab, english
**Created:** [December 29, 2022, 12:15pm UTC](https://forum.yunohost.org/t/reducing-docker-directory-size/22822 "2022-12-29T12:15:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yunohoster](https://forum.yunohost.org/letter_avatar_proxy/v4/letter/y/e47c2d/32.png) [@yunohoster](https://forum.yunohost.org/u/yunohoster)
#### Post date: [December 29, 2022, 12:15pm UTC](https://forum.yunohost.org/t/reducing-docker-directory-size/22822/1 "2022-12-29T12:15:24Z")

</div>

### My YunoHost server

**Hardware:** Hetzner VPS, 40 GB  
**YunoHost version:** 11.0.10.2  
**I have access to my server :** Through SSH  
**Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?** : no  
**Relevant apps** : GitLab

Disclaimer: I already solved this support request, and I’m posting it here for legacy and potentially any comments about how my solution has doomed my installation.

### Description of my issue

While exploring my YunoHost server in an attempt to increase available storage, I discovered that **`/var/lib/docker/` occupies ~6GiB**.

Given that docker was not installed on my system, it took me some time to determine that these directories were being created by GitLab’s CI pipelines.

Here’s the output of `tree /var/lib/docker` (negligible file/dir sizes are not indicated):

```plaintext
[5.7GiB] /var/lib/docker
├── [3.7 GiB] overlay2
│ ├── [520 MiB] 103222...
│ ├── [520 MiB] 194cda...
│ └── 20 more containers of various sizes
└── [1.9 GiB] volumes
    ├── [920 MiB] runner-d8ed6mmy-project-2-concurrent-0-cache-...
    ├── [500 MiB] runner-d8ed6mmy-project-4-concurrent-0-cache-...
    ├── a few other volumes of various sizes
    ├── backingFsBlockDev
    └── metadata.db
├── buildkit
├── containers
├── image
├── network
├── plugins
├── runtimes
├── swarm
├── tmp
└── trust

```

### Solution

After researching this, I did the following:

1. [Install docker](https://docs.docker.com/engine/install/debian/) to be able to interact with it (as it is not exposed by GitLab)
2. Have a look at how docker is being used on your system, to get an idea of what you can clean/should not touch
  - `sudo docker ps -a` for running containers
  - `sudo docker images` for existing images
  - `sudo docker volume ls` for existing volumes
  - `sudo docker images -f "dangling=true"` for images without containers
  - `sudo docker system df` for docker disk usage

3. Clean images and containers (based on discussions [here](https://stackoverflow.com/questions/46672001/is-it-safe-to-clean-docker-overlay2) and [here](https://stackoverflow.com/questions/66345607/docker-volume-cleanup-of-gitlab-runner))
  - `sudo docker image prune --all` for removing unused images
  - `sudo docker system prune --all` for removing unused data
  - in theory, we could also do `sudo docker volume prune --all` for removing unused volumes, but the disk usage by volumes was too low to justify finding out if it breaks anything.

Does anyone have comments on whether this is correct/doesn’t go far enough/is awful? Thanks!

NB: In case you’re reading this because you’re trying to reduce your disk usage, have a look at [removing unused node versions](https://forum.yunohost.org/t/how-to-free-up-space-node-uses-more-than-8-gb-space/17596) and [cleaning your logs](https://forum.yunohost.org/t/resolved-var-log-do-the-cleaning-properly/14473).

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [January 28, 2023, 12:15pm UTC](https://forum.yunohost.org/t/reducing-docker-directory-size/22822/2 "2023-01-28T12:15:56Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
