The Magic Docker Command
Sometimes, when you build multiple containers for different architectures, the container may exhibit unpredictable behavior. That happens to me when the PostgreSQL container throws some odd error messages.
The container instance started for a score of times before it threw 'initdb: error: could not create directory "/var/lib/postgresql/data/pg_wal": No space left on device'.
Of course, I have plenty of space, and no size limits have ever been applied. Plus, my application container build shows random build errors, most of which are related to PGP. And when you see such an error, you know it's time for a magic command prune.
There are three prune commands I use the most:
Command | Description |
---|---|
docker image prune | Clenup unused images and claims free space back. Also helps with removing broken or outdated layers, which you may wnat to build a new. |
docker container prune | Removes stopped containers. Helpful, if you dont build containers but use them, like memcached or postgrsql. |
docker volume prune | Removes unused volumes. However, it also eleminates odd continer's disk-related issues. |
As with real-life prunes, Docker's prune helps with image builds, keeps your disk clean, and makes your containers' history manageable.