Image & Container Cleanup
Images
Check which images are not being used and/or which images are not necessary to keep (even though they are not being used):
sudo docker image ls
Something like this is then displayed:
IMAGE ID DISK USAGE CONTENT SIZE EXTRA
alpine:latest a40c03cbb81c 8.44MB 0B
curlimages/curl:latest 9dcf90ad7bb5 24.2MB 0B
fedirz/faster-whisper-server:latest-cuda bd90135a6c6e 4.57GB 0B U
germannewsmaker/nexterm:latest 964ee298f99d 724MB 0B U
ghcr.io/berriai/litellm:v1.80.15-stable c5d16f3f9ef5 1.62GB 0B
ghcr.io/berriai/litellm:v1.81.3-stable 34e7c6e29c03 1.6GB 0B U
ghcr.io/docling-project/docling-serve-cu126:main 6c53729ba466 10GB 0B U
ghcr.io/open-webui/open-webui:v0.6.40 cd39b76e558e 4.32GB 0B
ghcr.io/open-webui/open-webui:v0.6.41 0f97e18d2372 4.33GB 0B
ghcr.io/open-webui/open-webui:v0.6.42 a146a7270d19 4.37GB 0B
ghcr.io/open-webui/open-webui:v0.7.0 969abf5e9d31 4.39GB 0B
ghcr.io/open-webui/open-webui:v0.8.0 67893bfb11cd 4.65GB 0B
ghcr.io/open-webui/open-webui:v0.8.1 ebb0056c7d6e 4.64GB 0B
ghcr.io/open-webui/open-webui:v0.8.2 ae525232f543 4.64GB 0B
ghcr.io/open-webui/open-webui:v0.8.7 78faef97cd5c 4.65GB 0B U
ghcr.io/wekan/wekan:v7.95 c079db795cf4 828MB 0B U
local:pyenv 0a6a5cfbe848 7.95GB 0B
mongo:6 d57fdb7f35f1 773MB 0B U
nvidia/cuda:12.4.1-base-ubuntu22.04 ca14dc8401b6 244MB 0B
nvidia/cuda:12.6.2-devel-ubuntu24.04 5f57c963b631 7.35GB 0B
nvidia/cuda:13.0.0-devel-ubuntu24.04 949aeb228afe 7.44GB 0B
onerahmet/openai-whisper-asr-webservice:latest-gpu 29ba705a475c 14.6GB 0B
postgres:16 47743fb02e4e 451MB 0B U
prom/prometheus:latest 937690d77350 367MB 0B U
Check for the images that dont have an 'U' in the 'EXTRA' column, that means that those images are being not currently used, they are the ones that you will potentially delete with:
sudo docker image rm <IMAGE-ID-1> <IMAGE-ID-2> ...
There's an automatic way of deleting unused images, more specifically images that are not referenced by any container (I prefer manually deleting the images, maybe there's images that will be used in the future):
docker image prune -a
It prompts you this:
WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
untagged: alpine:latest
untagged: alpine@sha256:3dcdb92d7432d56604d4545cbd324b14e647b313626d99b889d0626de158f73a
deleted: sha256:4e38e38c8ce0b8d9041a9c4fefe786631d1416225e13b0bfe8cfa2321aec4bba
deleted: sha256:4fe15f8d0ae69e169824f25f1d4da3015a48feeeeebb265cd2e328e15c6a869f
Containers
We delete containers that are older than 2 months. Check which ones meet this by looking at the STATUS column, it should have a value of Exited (0) >2 months ago.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7debefa86625 ghcr.io/berriai/litellm:v1.81.3-stable "docker/prod_entrypo…" 2 days ago Up 8 hours (healthy) 127.0.0.1:4000->4000/tcp litellm-stack-litellm-1
592d433ca37b postgres:16 "docker-entrypoint.s…" 2 days ago Up 2 days (healthy) 5432/tcp litellm_db
213d4cbca110 prom/prometheus "/bin/prometheus --c…" 2 days ago Up 8 hours 127.0.0.1:9090->9090/tcp litellm-stack-prometheus-1
36b8a9f977d2 fedirz/faster-whisper-server:latest-cuda "/opt/nvidia/nvidia_…" 6 days ago Up 2 days 8000/tcp whisper_gpu
f47304798adc germannewsmaker/nexterm:latest "docker-entrypoint.s…" 13 days ago Up 8 hours 127.0.0.1:6989->6989/tcp nexterm
1a3617106c6b ghcr.io/open-webui/open-webui:v0.8.7 "bash start.sh" 2 weeks ago Up 8 hours (healthy) 127.0.0.1:9005->8080/tcp beechat-open-webui-1
434c66299328 ghcr.io/wekan/wekan:v7.95 "bash -c 'ulimit -s …" 4 weeks ago Up 8 hours 127.0.0.1:9003->8080/tcp wekan-app
14d22881b9f7 mongo:6 "docker-entrypoint.s…" 4 weeks ago Up 2 days 27017/tcp wekan-db
16572281b98f ghcr.io/docling-project/docling-serve-cu126:main "container-entrypoin…" 5 weeks ago Up 2 days 8080/tcp, 0.0.0.0:5009->5001/tcp, [::]:5009->5001/tcp docling-serve
6816b7c7f92c local:pyenv "/bin/bash" 4 months ago Exited (0) 4 months ago instance-of-hsm4
70701e902fdc local:pyenv "/bin/bash" 5 months ago Exited (129) 5 months ago
Then identify them and delete them
sudo docker rm <CONTAINER-ID-1> <CONTAINER-ID-2> ...