Free Space from Docker container.
The below commands are useful to free up space from containers leave unused images, volumes, networks, logs.
From the cli where there is Docker installed run the below commands.
Commands
docker image prune -f -a
docker system prune --volumes -f -a
find /var/lib/docker/containers/ -type f -name "*.log" -delete
Download script
Or you can download the below shell script and add a Cron Job to run every 1 hour.
Download : docker-freeup-space.sh
Cron Job
Run crontab to add the job.
crontab -e
Then go to the end of the lines and add the below.
0 * * * * /path-of-the-script/docker-freeup-space.sh
Save and Exit
Done.