I checked many documentation sites and even a book. None of the resources clear this up for me.
The KB from Docker says yes, is it wrong?
https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
# syntax=docker/dockerfile:1
FROM ubuntu:18.04
COPY . /app
RUN make /app
CMD python /app/app.py
Each instruction creates one layer:
FROMcreates a layer from the ubuntu:18.04 Docker image.COPYadds files from your Docker client’s current directory.RUNbuilds your application with make.CMDspecifies what command to run within the container.
I want the list of instructions that don't create a layer. I know all create an intermediate layer, but I am concerned about the final layers in the image.
Every line in the
Dockerfilewill add a layer, includingCMD. You could refer to the terminology of layers:You can see that a layer is, in fact, just changes made to the file system. So, if a line in your
Dockerfileactually makes a difference to the image, it will add a layer.Of course, there are still some lines that won't change the Docker image, for example, Parser directives:
However, things like comments really do nothing for the final image. As they do not change the image, they do not add a layer.
You can also use
docker history <Image ID>to see the layers on an actual image.