Why is there a containerID-init layer created when a container is created from an image in Docker? Couldn't the new container have as parent the image?
The docker app init command is used to initialize a new Docker application project. If you run it on its own, it initializes a new empty project. If you point it to an existing docker-compose. yml file, it initializes a new project based on the Compose file.
A Docker image consists of several layers. Each layer corresponds to certain instructions in your Dockerfile . The following instructions create a layer: RUN , COPY , ADD . The other instructions will create intermediate layers and do not influence the size of your image.
The COPY command adds some files from your Docker client's current directory. The first RUN command builds your application using the make command, and writes the result to a new layer. The second RUN command removes a cache directory, and writes the result to a new layer.
Each containers has two layers, one (called the init layer), which is based on an image layer and a child of that which contains the actual container content. The init layer contains a few files that must always exist in Docker containers (e.g. /.dockerinit). Supported Filesystems
The containerID-init layer is the init layer of a container which is based on an image. It add some file into current container,include:
"/dev/pts": "dir",
"/dev/shm": "dir",
"/proc": "dir",
"/sys": "dir",
"/.dockerenv": "file",
"/etc/resolv.conf": "file",
"/etc/hosts": "file",
"/etc/hostname": "file",
"/dev/console": "file",
"/etc/mtab": "/proc/mounts",
code link
<container>-init
layer exists to create certain must exist files/directories(usually as mountpoints), so that docker can bind mount to these mountpoints without worrying they don't exist.
NOTE: init layer is RO
(READONLY), can not by modified.
These mountpoints are usually empty, and the following explains their purpose:
/proc
: in-memory data about processes and systemsys
: in-memory system file system/etc/hostname
: container hostname file, each container will have their own hostname, and bind mount to this file/etc/hosts
: hosts file, ip and name mapping/etc/resolv.conf
: DNS-related resolve conf fileIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With