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:
FROM
creates a layer from the ubuntu:18.04 Docker image.COPY
adds files from your Docker client’s current directory.RUN
builds your application with make.CMD
specifies 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.
The short answer is: no.
Here's an example of the python image history:
Note all the lines that say
"empty_layer": true
. Those indicate the step being run did not create a layer, and that's visible when the layers themself are listed:That shows only 8 filesystem layers while there were 17 steps in the history. Steps like
ENV
,CMD
, andLABEL
that don't create filesystem changes do not create a new layer.Another way to see the same result is to compare the output of
docker inspect $image --format '{{json .RootFS.Layers}}'
todocker history $image
and see the difference in lines (the values fromregctl
show the image on the registry and give visibility to fields likeempty_layer
).