My scrapbook about almost anything I stumble upon in my tech world. If you find anything useful don't forget to give thumbs-up :)

Breaking

Sunday, October 2, 2022

Few tips for your Docker Environment

If you are playing around docker, there is a time when you have to take care of housekeeping job as well. In today's post, we are going to discuss different options to perform cleanup activities, just keep in mind before executing any command that few of them can destroy your whole week of work. So understand and then execute. 
 
docker system prune 
    A very nice command to cleanup all the dangling items from your docker environment, by executing this command you are agree to clean below items -
  • all stopped containers
  • all dangling images
  • all build caches
  • all dangling network 
Manage docker logs
    By default there is no limit for your docker container logs, file can be as huge as the host OS system allowed but sometime it can be tricky to go through the logs if you have to debug any issue. We can restrict the max log file size for running containers as follows - 

cat /etc/docker/daemon.json
{
"log-opts": {"max-size":"10m", "max-file":"3"}
}
systemctl reload docker

If you don't want to change systemwide setting, you can use below flags when triggering docker run command to achieve the same.

docker run container \
--log-opt max-size=10m --log-opt max-file=3 \
....



Like the below page to get the update  
Facebook Page      Facebook Group      Twitter Feed      Telegram Group


No comments:

Post a Comment

Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.