This article is from Mr. Zhou Yang https://www.bilibili.com/vide…
Introduction to docker (3) common commands of docker
4： Docker image
4.1 what is docker image
Description:Image is a kind of lightweight and executable independent software package, which is used to package software runtime environment and software developed based on runtime environment. It contains all the contents needed to run a software, including code, runtime, library, environment variables and configuration files.
Unionfs (Federated file system): unionfs is a layered, lightweight and high-performance file system, which supports the file system modification as a single submission to overlay layer by layer. At the same time, it can mount different directories into a single virtual file system. The union file system is the foundation of docker image. Images can be inherited by layers. Based on the basic image (no parent image), various specific application images can be made.
Features: loading multiple file systems at one time, but only one file system can be seen from the outside. Joint loading will stack the file systems of each layer, so that the final file system will contain all the underlying files and directories
4.1.2 docker image loading principle
Docker image loading principle:
The image of docker is actually composed of file system layer by layer, which is called unionfs.
Bootfs (boot file system) mainly includes bootloader and kernel. Bootloader mainly loads kernel. When Linux starts, bootfs file system will be loaded. The bottom layer of docker image is bootfs. This layer is the same as our typical Linux / unix system, including boot loader and kernel. When the boot is loaded, the whole kernel will be in memory. At this time, the right to use the memory has been transferred from bootfs to the kernel. At this time, the system will also unload bootfs.
For a simplified OS, rootfs can be very small, just including the most basic commands, tools and libraries. Because the bottom layer directly uses the kernel of the host, it only needs to provide rootfs. It can be seen that for different Linux distributions, bootfs are basically the same, and rootfs will be different, so different distributions can share bootfs.
4.1.3 layered image
Take our pull as an example. In the process of downloading, we can see that the image of docker seems to be downloading layer by layer
Why use this layered structure
One of the biggest benefits is sharing resources
For example, if multiple images are constructed from the same base image, the host only needs to save a base image on the disk and load a base image in the memory to serve all containers. And every layer of the image can be shared.
4.2 features of docker image
Docker images are read-only
When the container starts, a new writable layer is loaded on top of the mirror.
This layer is often referred to as the “container layer” and the one below the “container layer” is called the “mirror layer”.
4.3 docker commit operation
Docker commit commits the container copy to make it a new image
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Options Description: -A: the image author submitted; -C: use dockerfile command to create image; -M: explanatory text at the time of submission; -P: pause the container when commit.
4.3.1 at present, there are three images:
4.3.2 starting Tomcat
4.3.3 add a home page
In the container, webapps creates a root folder
The host creates a index.html
Copy home page from host to container (easier way)Directory mountIt will be in the next chapter
Refresh the page to see your home page
Make complaints about Ali cloud EDS 1M is too slow to refresh for a long time.
4.3.4 the container submitted for modification becomes a new image
4.3.5 publish a container according to the newly generated image
Docker introduction to actual combat (5) docker container data volume