Doveps / mono

Code for Doveps projects
http://doveps.com
MIT License
0 stars 0 forks source link

2018-03-03 Study on Multi-Stage Builds #116

Closed erikkaBaguio closed 6 years ago

erikkaBaguio commented 6 years ago

I needed to understand about docker images and layering it using multi-stage builds. Referred to links:

https://www.youtube.com/watch?v=vlS5EiapiII https://blog.onebar.io/reducing-docker-image-size-using-multi-stage-build-4ec8ee111aae https://codefresh.io/docker-tutorial/docker-multi-stage-builds/ https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds

greenmoss commented 6 years ago

Cool; what did you learn about layering?

erikkaBaguio commented 6 years ago

Docker images consist of their own building blocks called image layers. Image layers is defined by each line in the docker file. Each docker image consists of multiple layers that that are combined into the final image. Layering speeds up the build process because images are reusable that means anything that happened before will just be stored in a cache for later use.

Then for the multi-stage builds, it uses single docker file and does not require scripting to hold multiple docker files together. In the docker file of a multi-stage builds, it allows multiple different base images and each of them begins a new stage of the build. It also allows to selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image. So it saves space and also speeds up its run time.