Dockerfile multi-stage build
Understanding of Docker multi-stage build:
Building an image requires a base image, and subsequent operations will be built based on the base image
There is a layered concept in the docker image file. Each time the RUN instruction is executed, the image will have one more layer, so the image size can be reduced by reducing the layers
When there are multiple froms, only the image of the last from is the root image of the image
Multi-stage build example in my own project deployment, here the binary compiled based on the golang base image is directly copied to the minimum image built based on alpine:
|
|