Member-only story

Downsizing Docker Images (~20X Improvement)

Sahu
4 min readJun 18, 2021

--

Boat Ride in the Canals. Amsterdam, Netherlands. @photosbysaurav on Instagram
Boat Ride in the Canals. Amsterdam, Netherlands. @photosbysaurav on Instagram

Note: This blog was originally published on my personal website: Downsizing Docker Images (~20X Improvement)

Docker is great, isn’t it? It has solved so many problems and helps developers easily deploy applications without complex configuration. But it’s also our responsibility to use it well. Docker images are basically templates that will create containers will which run our application — so it is important that we package our application which creates the most optimized and compact results. This is to ensure that our docker images can be used more effectively — deploying your image as a microservice? It’s best to have light-weight services. Writing these docker images to a container registry? Save space and store the most optimized docker images.

Note: Even though we’re going to take a look at a sample nestjs application, this applies to any sort of application you’re building.

You can find the entire repository here and you can experiment with this. So, to give you a brief about the app, it’s a basic hello API which has one route that returns some information about itself. If you run the app locally, with a PORT=8080 npm start you can see the response by sending a request to GET /

Here’s a sample response:

{
"data": {
"app": "hello",
"version"

--

--

Sahu
Sahu

Written by Sahu

All opinions shared are personal and not influenced by my Employer • Senior Software Engineer @ McKinsey & Company

Responses (1)