Get Notification: Monitor Your Docker Image Sizing

dennyzhang
Jul 23, 2017 · 3 min read

With Docker deployment, smaller images are usually better.

But your docker images will keep changing. And you just don’t remember to check it for a while. Then someday you happen to find out some huge images in your deployment pipeline. Feel uncomfortable, don’t you? Any thoughts about how to improve it?

My answer is like always: Monitor That! And Get Slack notifications.

Enclosed is my approach. Check it out! And discuss with me, my friends.


Original Article: https://dennyzhang.com/monitor_image_size

Checking docker image size is super easy.

docker images | grep $image_name

We all want small images.

  1. The question is how small is small enough? It actually depends on your expectation, your project, etc.
  2. And you don’t set one expectation for all images, do you? More likely it would be some images should be less than 50MB, while some other should be less than 300MB, etc.

Examine it manually? It works.

But you can do better. I trust you! Maybe you can automate the check. What’s better, make the solution general. The same approach should apply to different projects with no extra effort.

Here comes my suggestion: detect_big_docker_image.py.

  1. By default, the script examines all docker images in the docker host machine.
  2. Different images can have different check threshold.
  3. We can skip check for certain docker images.

Why Python instead of Shell? (See GoodBye Shell, Hello Python!)

I love Jenkins. (See 5 Reasons Why Jenkins Is So Useful And Popular).

Thus I usually create a Jenkins job, which runs the check weekly.

If the job fails, I will get slack notifications.


Check more in My LinkedIn Discussion1, Discussion2!

(Connect with me in LinkedIn)


dennyzhang

Written by

DevOps Guy & Blogger: https://www.dennyzhang.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade