Docker container File System detailed introduction (text) _docker

Source: Internet
Author: User
Tags json

Docker container File system

DockerfileSoftware is the raw material, Docker镜像 is the software delivery, but it Docker容器 can be considered as the operating state of the software. From the point of view of application software, Dockerfile, Docker mirror and Docker container represent three different stages of software respectively, dockerfile oriented development, Docker mirror becomes delivery standard, Docker container involves deployment and Operation dimension, three is indispensable, The resultant force acts as the cornerstone of the Docker system.

Docker mirroring

Docker Mirror Image is the product of Dockerfile, is the premise of Docker containers, the meaning of the past. Docker technology development for more than two years, I believe that we have heard of Docker most of the use of 联合文件系统 (Union filesystem) for Docker containers to provide file system services.

For Docker mirroring, you have the following characteristics:

    1. Generated by Dockerfile
    2. Rendering hierarchy
    3. Per-layer mirroring contains: mirrored files and mirrored JSON metadata information

Docker container

The Docker container is an embodiment of the operating state of the Docker mirror. Generally, it is on top of the Docker mirror that the process runs. There are two ways in which a process can be started, in which the user may choose to run a command that they specify separately, or you can choose to run the command specified within the Docker mirror.

The file system of the Docker container, which can be said to be provided mostly by Docker mirrors. Why is that most? In fact, there is a reason, although the image content is many, but still not all. Next, I'll show you what's in the Docker mirror, and what's in the Docker container that's not in the Docker mirror.

Docker container File system

So let's take a look at the file system of the Docker container:

The above figure from a more comprehensive point of view Dockerfile , Docker镜像 and the Docker容器 relationship between the three.

Dockerfile embodies

The Docker container is already running, but we can still find the shadow of Dockerfile. In the diagram above, we can find that Docker容器 attachment Docker镜像 , and that is the Docker镜像 Dockerfile case:

From ubuntu:14.04
ADD run.sh/
volume/data
CMD ["./run.sh"]

We can see that each command in the above dockerfile is in the form of a separate mirror layer in the Docker mirror.

Docker Mirror Reflection

There is no doubt that Docker mirrors are built from dockerfile, and we can see that the next 4 layers of the graph are marked as Docker mirrors. As the core of Docker technology, we have to understand how Docker constructs mirrors and what the artifacts are after Docker mirroring is built.

After first contact with Docker, understanding the Docker mirroring of hierarchy management, it is easy to assume that each layer docker mirror contains the corresponding file system files. In fact, the above 4 orders in Dockerfile, is a good corroboration.

FROM ubuntu:14.04: Set up the underlying mirror, where all the mirror layers of the underlying mirror ubuntu:14.04 are used, and for simplicity, it is shown as a whole.

ADD run.sh /: Adds the file run.sh of the Dockerfile directory to the mirrored root directory, at which point the new layer mirrors only one content, that is, the run.sh under the root directory.

VOLUME /data: Sets the volume of the Mirror, volume the path inside the container is/data. Note that no files are added to the new layer's mirror at this time, but the mirrored JSON file is updated to get this information when the container is started from this mirror.

CMD ["./run.sh"]: Sets the default execution portal for mirroring, which also does not add any files to the new mirror, but only updates the new mirrored JSON file on the basis of a mirrored JSON file on the previous layer. Docker container manifests

Involves the Docker container, is the dynamic content, all seems to have the life. As mentioned above, the file system of the Docker container contains not only Docker mirrors. This is true, the figure of the top two layer, is Docker for the Docker container new content, and these two layers just do not belong to mirror category.

The two layers are the initial layer () of the Docker container () Init Layer and the read-write layer ( Read-Write Layer ), and most of the initial layer is the container environment information, such as the container host name, host information and domain name service file.

To see the read-write layer, the role of this layer is very large, docker of the mirror layer and the top two add up, the process within the Docker container only write permission to the read-write layer, the other layer for the process is read-only ( Read-Only ). such as Aufs and other file systems, write the underlying image content will be involved COW(Copy-on-Write)技术 . In addition, the volume and containers of hosts, hostname, resolv.conf files will be mounted here. Additional attention is required: Although the Docker container has the ability to see volume and hosts files in the read-write layer, it is only a mount point, and the real content is on the host.

Summarize

Docker Mirror is static, Docker container is dynamic, there are countless relations between them. From the point of view of Docker container file system, I believe it will be of great help to everyone.

Docker image and Docker container file system, is absolutely very meticulous content, based on these concepts, there are so many interesting topics can be launched, this series will be followed by a number of articles to analyze:

1. Deep understanding of Docker mirror Size

2. In fact, Docker commit is simple

3. The difference between Docker save and Docker export

4. Why some container files cannot be moved

5. To break the Mnt namespace container volume

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.