The underlying principle of docker will take you to heaven

1. How to see the level of docker

First check which mirrors are on the current machine

docker images

Choose to see the level of mysql here

docker image inspect mysql:5.7.29 command. The RootFS part represents hierarchical information.

 2. View docker system information

Because the docker of this machine is not installed by me, so I don’t know where the specific root directory is, you can use the following command

docker info

 You can see the docker information above

3. The significance of each folder in Docker's default working directory

Docker's default working directory is /var/lib/docker/, which contains all Docker data, including images, containers, volumes, networks, and more. The following are some common subdirectories and their meanings under the /var/lib/docker/ directory:

1. /var/lib/docker/containers/: Contains the data of all Docker containers. Each container will create a subdirectory under this directory to store the relevant data of the container, such as container metadata, logs and file systems, etc. .

2. /var/lib/docker/image/: Contains the data of all Docker images. Each image will create a subdirectory under this directory to store the relevant data of the image, such as image metadata, layer information, etc.

3. /var/lib/docker/volumes/: Contains the data of all Docker volumes. Each volume will create a subdirectory under this directory to store the relevant data of the volume, such as the metadata of the volume and the files in the volume.

4. /var/lib/docker/network/: Contains data of all Docker networks. Each network will create a subdirectory under this directory to store relevant data of the network, such as network metadata and configuration.

5. /var/lib/docker/plugins/: Contains the data of all Docker plugins. Each plugin will create a subdirectory under this directory to store the relevant data of the plugin, such as metadata and configuration of the plugin.

6. /var/lib/docker/swarm/: Contains relevant data of Docker Swarm, such as node metadata, service configuration, certificates and keys, etc.

7./var/lib/docker/overlay2 : the actual storage directory of the image and container layer files

4. Where is the log of the docker daemon

Logs for the Docker daemon are recorded in syslog, the exact location and naming may vary depending on the operating system. Here are some common operating systems and corresponding Docker log file locations:

- Ubuntu 16.04 and earlier: /var/log/upstart/docker.log
- Ubuntu 18.04 and later: /var/log/syslog
- CentOS 7: /var/log/messages
- Debian/Ubuntu: /var/ log/daemon.log

5. Principle of docker Overlay2 file system

Pull an nginx image and observe the pulling process: you can see that the image is divided into 6 layers for pulling.

There are also 6 more folders in the /var/lib/docker/overlay2/ directory

 You can view the hierarchy through the above docker image inspect nginx

When downloading the image, Docker Daemon will check the image layer in the image and compare it with the image layer in the host file system. If it exists, it will not download it, and only download the image layer that does not exist.

Reason for stratification:

  1. One of the biggest benefits of layering is sharing resources
  2. If multiple images are built from the same base image, the host only needs to save one base image on disk;
  3. At the same time, only one base image needs to be loaded in the memory to serve all containers, and each layer of the image can be shared.

Guess you like

Origin blog.csdn.net/perfect2011/article/details/130490943