A view of the Docker container file system

Source: Internet
Author: User

Dockerfileis the raw material of the software, Docker镜像 is the delivery of the software, but it Docker容器 can be considered as the operating state of the software. From the perspective of application software, Dockerfile, Docker images and Docker containers represent three different stages of the software, Dockerfile development-oriented, Docker mirroring as a delivery standard, Docker containers involving deployment and operations, three indispensable, Join forces as the cornerstone of the Docker system.

Docker image

Docker image is the product of Dockerfile, is the premise of Docker container, it has a great deal of meaning. Docker technology has been growing for more than two years, and I'm sure you've heard that Docker mostly uses 联合文件系统 (Union Filesystem) to provide file system services for Docker containers.

For Docker mirroring, the following features are available:

    • Generated by Dockerfile

    • Rendering Hierarchy

    • Each layer image contains: image files and mirrored JSON metadata information

Docker container

The Docker container is the running state of the Docker image. In summary, the process is run on top of the Docker image. There are two ways that a process can be started, which allows the user to choose to run their own specified commands, or to run the commands specified inside the Docker image.

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

Docker container File system

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

From a more comprehensive point of view Dockerfile , the Docker镜像 relationship with the Docker容器 three.

Dockerfile Embodiment

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

FROM ubuntu:14.04ADD run.sh /VOLUME /dataCMD ["./run.sh"]

As we can see, each command in the above dockerfile is in the form of a separate mirrored layer in the Docker image.

The Docker image reflects

There is no doubt that the Docker image is built from Dockerfile, and we can see that the next 4 layers in the diagram are labeled Docker images. As the core of Docker technology, we have to understand how Docker constructs mirrors and what the product of the Docker image is built upon.

After first contacting Docker and understanding the hierarchical managed Docker image, it is easy to assume that each layer of Docker images contains corresponding file system files. In fact, the above Dockerfile 4 commands, it is a very good evidence.

    • FROM ubuntu:14.04: Sets the base image, which uses all the mirrored layers of the underlying image ubuntu:14.04, for simplicity, as an overall presentation.
    • ADD run.sh /: Add the file of the directory where Dockerfile is run.sh to the root of the mirror, at which point the new layer of mirroring has only one content, that is, the run.sh under the root directory.
    • VOLUME /data: Sets the volume of the mirror, the path of this volume inside the container is/data. It is important to note that no files are added to the new layer of mirrors at this time, but the mirrored JSON file is updated to obtain this information when the container is launched through this image.
    • CMD ["./run.sh"]: Sets the default execution entry for the mirror, which also does not add any files to the new image, but updates the JSON file for the new image only on the basis of the previous layer of mirrored JSON files.
Docker Container embodies

When it comes to Docker containers, it's dynamic content, and everything seems to be alive. As mentioned above, the Docker container's file system contains not only Docker images. This is true, the top two floor of the figure, Docker is the new content of the Docker container, and these two layers are not part of the mirror category.

The two tiers are the initial layer ( Init Layer ) and the read/write layer () of the Docker container, and the Read-Write Layer initial layer is mostly initialized with the container environment information, such as container hostname, host hostname and domain Name service file.

Look at the read-write layer, the role of this layer is very large, the mirror layer of Docker and the top two layers together, the process in the Docker container only has write permission to the read-write layer, the other layers are read-only ( Read-Only ). such as the Aufs file system, write the underlying image content will be involved COW(Copy-on-Write)技术 . In addition, the hosts, hostname, resolv.conf files for volume and containers will be attached here. It is important to note that although the Docker container has the ability to see content such as volume and hosts files in the read-write layer, it is only a mount point and the real content resides on the host.

Summarize

Docker mirrors are static, and Docker containers are dynamic, and there are countless relationships between them. From the perspective of the Docker container file system, I am sure it will be of great help to everyone.

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

1. Deep understanding of Docker image size

2. Actually, Docker commit is simple.

3. What you have to say is the difference between Docker save and Docker export

4. Why some container files cannot be moved

5. Breaking the volume of the Mnt namespace container

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

A view of the Docker container file system

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.