I decided to touch the Docker-technology to launch applications, and in the process of reading a question appeared.

In some sources the term "layer" is used, in others "container" . Is this the same thing - "image + new application"?

For example, nginx is added to the image of the empty system - LAYER 1 is ready. UWSGI added to the image of an empty system - LAYER 2 is ready.

Are containers already included in the images? Or is a container an image running on a host with the necessary parameters?

1 answer 1

The image is meta-information + aufs section with files. A container is an image that is started / stopped. The aufs file section consists of layers. A layer is a section nugget that contains modified and new files. All layers inside the section's aufs are read-only, only the newest (top) layer can be used for writing. When a container is launched, a new layer is created and all changes fall into it.

Suppose there is such an aufs section :

Слои Содержимое +-----------+ 3 | file1.txt | +-----------+ 2 | file3.txt | +-----------+ 1 | file1.txt | | file2.txt | +-----------+ 

The process inside this section will see the files.

  file1.txt из 3 слоя file2.txt из 1 слоя file3.txt из 2 слоя 

If the process tries to write something to the files file2.txt, file4.txt and delete file1.txt, then it’s like this

 Слои Содержимое +-------------+ 3 | file2.txt | | file4.txt | | <directory> | - директория это файл в котором будет +-------------+ удалена информация о файле file1.txt 3 | file1.txt | т.е. file1.txt пропадет. +-------------+ 2 | file3.txt | +-------------+ 1 | file1.txt | | file2.txt | +-------------+ 

In Unix systems, directories are files that contain information about other files. When you delete a file from the disk, the file of the directory is changed.

  • added pro layer - Mikhail Vaysman
  • Oh thanks. the image structure resembles a git repository - while1pass
  • one
    Yes. similar idea. and docker has a diff that shows the difference between images. - Mikhail Vaysman