DEV Community

Cover image for Build a super minimalistic Docker Image to run your Golang App

Build a super minimalistic Docker Image to run your Golang App

Christian Seki on March 24, 2021

Why should you care about Docker Images size ? Basically, to speeds up building, deploying and also cut costs with storage and network e...
Collapse
 
kcq profile image
Kyle Quest • Edited

Another option to consider is DockerSlim... You get to keep a simple Dockerfile. No need for multi-stage and you don't need to worry about missing the certificates or any other extra dependencies.

Take a look at this example github.com/docker-slim/examples/tr...

The original container image is 648MB and it becomes 9.3MB after DockerSlim is done with it.

Collapse
 
chseki profile image
Christian Seki

I saw the README.md from the DockerSlim project and it's super interesting. I'll definitely try it, thanks for sharing Kyle!

Collapse
 
kcq profile image
Kyle Quest

happy to do an overview to show some of its lesser known capabilities and its more advanced use case if you are interested

Collapse
 
brandoncatubig profile image
Brandon Catubig

Be aware when using scratch that no SSL certificates are present in the image. You'll have to copy them in.

See stackoverflow.com/a/65298923

Collapse
 
chseki profile image
Christian Seki

Good point Brandon, thanks!

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

You can google for Distroless. Many images in other languages are provided by Google. However, not yet Node.js.

Collapse
 
chseki profile image
Christian Seki

I've never heard of this Image, thanks for sharing !

Collapse
 
henrik_oliveira profile image
Henrique Oliveira

Lol, that is super cool, that image is minimal. Thanks for tuto.

Collapse
 
bscott profile image
Brian Scott

Great Post - Also look at buildpacks.io/

Collapse
 
chseki profile image
Christian Seki

Thank you Brian.
I'll take a look, thanks for sharing !

Collapse
 
gusandrioli profile image
Gustavo Andrioli

Awesome, will definitely apply these to my go apps