V-3.28 (Creating Docker Images)
V-3.28 (Creating Docker Images)
Docker file have a lines of configuration places inside of it. This configuration define how our container
behaves.
Once we create a docker file. We pass it on to the docker client(docker cli) and docker cli provide the file
to the docker server. Docker server goes through all the configurations and then build a useable image
that can be used to startup a new container.
Run instruction is used to run a command while we are preparing our custom image
We want to use the Alpine docker image as kind of initial operating system or starting point for the
image that we are creating.
What happens?
When we run docker build . we are giving our docker file to the docker cli. Build command is all about
taking docker file and generating an image out of it.
In step 2: It creates a temporary container by taking out the image that was sourced in previous step.
Before going to step 3/ after the reddis package has installed we took a filesystem snapshot of the
container and then we stopped it entirely.
In step 3: It looks back to the previous step for the image that was created. We take the image
filesystem snapshot and stuck it into the container hard drive.
By taking the snapshot of the file system. It shutdowns the container by taking snapshot of the
filesystem and saved it as an image
End Result:
For every step in the docker file, we essentially take the image that was generated during the previous
step. We created a new container out of it. We execute the command in the container or make change
in it’s file system. We then look at that container and then take a snapshot of filesystem and then save it
as an image or output(input for me) for the next instruction along the chain. When there is no more
instructions to execute, the image that was generated by the last step is the output from the entire
process as the final image.
Adding cache version of redis to alpine and cached version of gcc to reddis instruction generated image