How to shrink Docker images by 90%
Recently I stumbled across a tool to reduce the size of docker images: docker-slim. Today I gave it a try and want to share my experience.
Preliminaries
My machine runs on OS X and I have Docker and Homebrew installed. Personally I prefer httpie over curl to test HTTP applications, but you can use whatever you like most.
Nodejs and Hello World
The following Dockerfile starts a container listening on port 5050.
Let’s run it and test it.
The Hello-World container works as expected but requires 998MB of disk space. Let’s see how much docker-slim can save us.
Optimize image with docker-slim
This seems nice: the image size is reduced by over 900MB to 92.2MB. This not only saves disk space but network as well, since we tend to ship our Docker images somewhere.
I hope you find this blog post helpful. If you have any feedback, feel free to contact us.