I am trying to understand the docker images a bit better. Most of the instructions in a dockerfile creates a layer.
So when we have the command:
COPY hom* /mydir/
this creates a layer and according to the doc
The COPY instruction copies new files or directories from <src> and adds them to the filesystem of the container at the path <dest>.
It says in the container and not the image though. Does that mean that the layer itself holds the files and the instruction and when the docker runs the container the layer is essentially an execution at runtime of the command?
I am a bit confused on what constitutes the layer at a lower level
Yes.
Yes, in the form of history. See
docker history <image>
.No, the command was executed in the past and resulted in a layer consisting of files. When the image is executed, the layers of files are laid on top of each other, resulting in a file system.
Files, files everywhere. This also depends on your used dockerd storage driver and file system. Typically, with OverlayFS, there are just directories in /var/lib/docker/overlay2 with files. When image is started, directories are "laid on top of each other" with OverlayFS resulting in a file system of all files from all folders.
You might also be interested in https://docs.docker.com/storage/storagedriver/select-storage-driver/ in particular https://docs.docker.com/storage/storagedriver/overlayfs-driver/#how-the-overlay2-driver-works .