Run all commands below on the machine whose disk you are cleaning. Docker cache on a Mac has no bearing on VPS free space. Connect through SSH first for server cleanup. Clean up after operations finish; preserve current and previous releases. Automatic old-release cleanup is not yet available.
1. Check disk usage
df -h /
docker system df
docker buildx du
The first command shows filesystem free space; the second shows images, containers, and Docker cache; the third shows current builder cache entries. Shared layers are used by multiple images or cache. Removing one tag may free only a few kilobytes even if its displayed size is hundreds of megabytes.
2. Clean old build cache
Cache speeds up build and contains no working application data. Start with entries unused for the past day:
docker buildx prune --filter 'until=24h'
Docker asks for confirmation. Enter y. Containers, prepared images, database, and media are preserved; future builds may take longer. The command affects the selected builder. To remove one entry, take its ID from docker buildx du:
docker buildx prune --filter 'id=ID_ЗАПИСИ'
To remove all available cache for this builder:
docker buildx prune
Do not expect to free the sum of displayed sizes: shared layers of needed images remain. Docker Desktop virtual-disk space reclamation may not appear immediately on the Mac.
3. Preserve needed releases before removing images
Paths below are examples. Replace example_project and production with your profile values; runtime root is in Deployment → Runtime directory.
jq '{id, backend, admin, ops, services, imageArchive}' \
/srv/admingen/example_project/production/state/current.json \
/srv/admingen/example_project/production/state/previous.json
docker image ls
docker ps -a
If previous.json does not exist yet, this is the first release: inspect current.json only. Preserve exact backend/admin/ops for current and previous releases, service images in use, and images of other environments and unfinished operations. For an old unneeded image, specify an exact tag from docker image ls:
docker image rm ПОЛНОЕ_ИМЯ_СТАРОГО_ОБРАЗА:ТЕГ
Do not add --force. Do not use docker image prune -a or docker system prune -a as ordinary cleanup: they may delete a preserved rollback version because no container currently uses it.
4. Inspect image archives
Source/Archive leaves a file beside release JSON in the checkout and a copy in runtime/image-archives. Docker prune does not remove these ordinary files. With example checkout /home/deploy/projects/example-project:
find /home/deploy/projects/example-project \
-maxdepth 1 -type f -name '*.images.tar' -exec du -h {} \;
du -ah /srv/admingen/example_project/production/image-archives/ | sort -h
In current.json/previous.json, imageArchive.file gives the checkout archive name; imageArchive.sha256 gives the runtime copy name, with .tar added. For example, source-...images.tar and <sha256>.tar may contain the same release. Both archives are not always needed, but a simple policy preserves both copies for current and previous releases.
Delete specific old files only, rather than the entire directory:
rm -i /home/deploy/projects/example-project/ИМЯ_СТАРОГО_РЕЛИЗА.images.tar
rm -i /srv/admingen/example_project/production/image-archives/SHA256_СТАРОГО_РЕЛИЗА.tar
-i asks for confirmation of each deletion. Removing an archive loses that local copy of the old version. Archives are not database dumps and contain no user-uploaded images.
5. Other disk usage
On the VPS:
sudo du -xhd1 / 2>/dev/null | sort -h
sudo du -xhd1 /var /root /home /srv /usr 2>/dev/null | sort -h
sudo du -xhd1 /var/lib 2>/dev/null | sort -h
sudo find / -xdev -type f -size +200M -exec du -h {} + 2>/dev/null | sort -h
journalctl --disk-usage
du shows directory sizes; -x does not traverse other filesystems. find lists large files. For a large directory, inspect it with another du -xhd1 command.
For a large system journal, remove entries older than a week:
sudo journalctl --vacuum-time=7d
This deletes old system logs, rather than Docker container logs. If space is held by deleted files still open in processes and lsof is installed:
sudo lsof +L1
Do not terminate processes at random. PostgreSQL data, media, backups, and swap are not Docker cache. Do not clean /var/lib/docker or /var/lib/containerd manually: manage them through Docker. Do not remove working data, secrets, pki, or state directories to free space.
6. Check the result
df -h /
docker system df
For data preservation, use backup; for Docker image roles, see backend/admin/ops explained.