A container image is built from layers rather than stored as one indivisible filesystem. A layer can be reused by multiple images. Docker stores a shared layer once, and a host downloading another image needs to fetch only the layers it does not already have. section 2.1.2
Layers from a Dockerfile
Start with `FROM node:23-alpine`, then use `COPY app.js /app.js`, `COPY html/ /html`, and `ENTRYPOINT ["node", "app.js"]`. Docker builds on the base image layer by layer: the two COPY directives add files, and the ENTRYPOINT directive specifies the startup command. Run `docker history kiada:latest` to see the resulting layers, their sizes, and the directives that created them. The newest layers appear first. section 2.2.2
$ docker history kiada:latest IMAGE CREATED CREATED BY SIZE afeb94f9465c 13m ago ENTRYPOINT ["node" "app.js"] 0B #1 <missing> 13m ago COPY html/ /html 533kB #1 <missing> 13m ago COPY app.js /app.js 2.9kB #1 <missing> 17h ago CMD ["node"] 0B #2 <missing> 17h ago ENTRYPOINT ["docker-entrypoint.sh"] 0B #2 <missing> 17h ago COPY docker-entrypoint.sh /usr/l... 388B #2 <missing> 17h ago RUN /bin/sh -c set -ex && save... 7.18MB #2 <missing> 17h ago ENV YARN_VERSION=1.22.22 0B #2 <missing> 17h ago RUN /bin/sh -c ARCH= OPENSSL_ARC... 143MB #2 <missing> 17h ago ENV NODE_VERSION=23.4.0 #2 <missing> 17h ago RUN /bin/sh -c groupadd --gid 10... 8.9kB #2 <missing> 9d ago # debian.sh --arch 'amd64' out/... 74.8MB #2
Compare the file-adding COPY layers with the 0B ENTRYPOINT layer, then look below them for layers inherited from the base image. section 2.2.2
Sharing an image layer does not mean containers share their changes. Each container uses the image’s read-only layers beneath its own read/write layer. If an application changes a file from a read-only layer, copy-on-write places a copy in that container’s read/write layer and changes it there. Other containers continue to see their own filesystem state. section 2.1.2




