I am reading the official Docker docs, and it is unclear to me how many layers will be created for the below dockerfile.
# syntax=docker/dockerfile:1
FROM ubuntu:18.04
LABEL org.opencontainers.image.authors="[email protected]"
COPY . /app
RUN make /app
RUN rm -r $HOME/.cache
CMD python /app/app.py
As per my understanding, four layers will be created - first from FROM command, then COPY command, and then two layers from each RUN command.
I have another question: how many layers does the FROM command create? Does it create only one layer, or can it create more than one layer?



The key concept is:
so in your example, the
COPYcommand and theRUNcommands will create one layer each (so 3 in total).These layers are added to whatever layers the base image has.
given:
then:
so you end up with whatever layers you had in the base image, plus the new layers.
FROMin itself does not create a layer.