A chart to see the Docker container file system

Label Docker
340 people read comment(0) Collection Report

DockerfileIs the raw material of the software,Docker mirrorIs the delivery of software products, andDocker containerIt can be considered as the running state of the software. From the application point of view, the three different stages of Dockerfile, docker mirror and docker container, respectively, on behalf of the software, Dockerfile oriented development and docker image become delivery standards, docker container relates to the deployment and maintenance, all three are indispensable together to act as cornerstone docker.

Docker mirror

Docker image is a product of Dockerfile, is a prerequisite for the Docker container, a link. Docker technology development for more than two years, I believe we have heard very early Docker mostly usedJoint file system(Filesystem Union) to provide a file system service for the Docker container.

On the Docker mirror, there are the following characteristics:

  • Generated by Dockerfile

  • Presentation hierarchy

  • Each layer contains: mirror image file and JSON metadata information

Docker container

Docker container is the running state of Docker mirror image. Generally speaking, that is, on the Docker mirror, the running process. There are two ways to start the process, the user can choose to run their own separate specified command, you can also choose to run the Docker mirror inside the specified command.

Docker container file system, it can be said that most of the Docker image to provide. Why do you say it is the most? In fact, there is a reason, the image content, although many, but still not all. Below, I will take everyone to see what Docker mirror, and the contents of the Docker container is not in the Docker image.

Docker container file system

Let us look at the Docker container file system:

Write the picture here.

The picture is from a more comprehensive perspective.Dockerfile,Docker mirrorandDocker containerThe relationship between the three.

Dockerfile embodiment

The Docker container is already running, but go back, we can still find the shadow of Dockerfile. In the picture above, we can find,Docker containerAttachmentDocker mirrorBut,Docker mirrorTheDockerfileThis is the way:

FROMUbuntu:Fourteen point zero four /

We can see that each command in the Dockerfile is present in the form of an independent mirror layer in the Docker image.

Docker mirror image

There is no doubt that the Docker image is constructed by Dockerfile, and we can see that the 4 layer in the graph is marked as a Docker image. As the core of Docker technology, we have to understand how Docker constructs the mirror image, and what is the product of the Docker mirror image building.

First contact Docker, to understand the level of management of the Docker mirror, it is easy to think: each layer of Docker images are contained in the corresponding file system file. In fact, otherwise, the above 4 commands in the Dockerfile, it is a good evidence.

  • Ubuntu:14.04 FROM: set the base image, and then use all the mirror layers of the base mirror ubuntu:14.04 as a whole.
  • ADD /: Dockerfile directory file to the root directory of the mirror, this time the new layer of the image is only one content, that is, the root directory
  • /data VOLUMESetting the image of the VOLUME, this VOLUME the path inside the container is /data. It should be noted that this does not add any files to the new layer of the image, but the JSON file is updated to get this information from the image to start the container.
  • CMD ["./"]Setting the default execution entry for the mirror, this command will not add any files in the new mirror image, just update the newly built JSON file based on the last layer of the JSON file.

Docker container embodiment

Related to the Docker container, it is dynamic content, everything seems to have a life. As mentioned above, the file system of the Docker container not only contains the Docker image. Remark is not false, figure in the top two layers, is a docker docker container new content, and the two layers just does not belong to category of image.

These two layers are the initial layer of the Docker container.Layer Init(in) with a read and write layerReadWrite LayerIn the initial layer, most of the initialization of the container environment, and the container related environmental information, such as the container host name, host host information and domain name service files, etc..

Again to see readable writing layer, this layer effect is very big, docker mirror layers and on top of the two layers together, docker container in the process only to read write have write permission, other layers to process are read-only (Read-Only). Such as AUFS and other file systems, write the lower image content will involveCOW (Copy-on-Write) technology. In addition, about VOLUME and hosts, hostname, resolv.conf container file will mount here. Need to pay extra attention to is: Although docker container has the ability in read / write layer to see volume and the hosts file content, but that is only the mount point, the real content in the host.


Docker mirror is static, Docker container is dynamic, there is a close relationship between the two. Docker container file system from the perspective of both, I believe 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 topic can be launched, this series will follow the following articles to analyze:

1 a deep understanding of the size of the Docker image

2 in fact, commit docker is very simple

3 have to say that the save docker and export docker difference

4 why some container files can not move

5 break Namespace MNT container VOLUME

Welcome to pay attention to the Docker source code analysis of the public number

step on
Guess you're looking for
View comments
* the above user comments only represent their personal views, does not represent the views or position of the CSDN website
    personal data
    • Visit84614 times
    • Integral:One thousand three hundred and fifty-six
    • Grade
    • Rank:18466th name
    • Original47
    • Reproduced:0
    • Translation:1
    • Comments:50
    Blog column
    Contact information
    Latest comments