Home > OS >  Docker question: Does Docker link FROM images at runtime or during build?
Docker question: Does Docker link FROM images at runtime or during build?

Time:03-03

Does Docker link images at build time or execution time? I am presenting a very simple case here to demonstrate my dilemma but I am presently rebuilding a chain of Docker files every time I change the base docker image and Im not sure if I even need to.

I have two docker files:

my base-docker-file contains

# this is not based on another image

RUN build commands here 

which I build with

docker build --no-cache -t base-image -f base-docker-file.

and my from-docker-file here:

# this is based on the base-image
FROM base-image

RUN build commands here 

which I build with

docker build --no-cache -t from-image -f from-docker-file.

Based on this simple setup, do I need to rebuild my from-image whenever I make a change to my base-image or does image linking occur at run time?

CodePudding user response:

Multi-stage build allows you to isolate images in one dockerfile.

Perhaps this will help you: https://docs.docker.com/develop/develop-images/multistage-build/

CodePudding user response:

you will have to build each time if you make a change to the base-image. You could add these individual commands in a script to be executed together rather than running them separate everytime

  • Related