Sorry, it is again about Docker 🙂 I use it more and more last days.
At some point we need to rebuild images from scratch without using cache. You can use following commands to achieve best results:
docker system prune
docker-compose build --no-cache
Then you can use up command as usual:
Recently I had an issue with Docker Compose startup order. PostgreSQL was running after Django’s web container so it was impossible to make proper connection especially while first run. The solution is to write some script which will check status of PostgreSQL before running web worker. I found initial version of it on Docker’s web site:
But it was not working without postgres’ password. After a little research I came up with following update. You need to add PGPASSWORD=$POSTGRES_PASSWORD env variable before calling psql command.
After few additional steps (you can read about them on my medium post) it now works just fine.
I did pull request with regarding changes to Docker’s documentation and it is accepted.
Task: remove everything related to Docker and cleanup
sudo docker system prune
If you want to remove any stopped containers and all unused images, not just dangling images use it with “-a” option:
sudo docker system prune -a
Why: after playing with Docker and Docker Compose at some point you may have tons of unused images and containers which occupy disk space. I do not like keeping unnecessary files on my system 🙂
How To Remove Docker Images, Containers, and Volumes (DigitalOcean)
Docker Pruning (official docs)