What is there in the mirror image of Docker, where is it?

label Docker
464 people read comment(2) Collection report

It is said that the important thing to say three times, then I express my personal point of view:Docker mirrorIs the soul of Docker.

The first two to speak on the Docker image of the description, has been from a macro point of view one or two. Once you master the Docker for the level of the management of the image, as well as the Docker mirror the size of the real situation, then come to understand the contents of the Docker mirror and storage, it is a lot easier.

Docker mirror content

There is always the first time for the Docker mirror image, since then, of course, there is little growth, the author's own understanding of the process may wish to share with you:

1 initial contact DockerI believe that a lot of fans will be like me, there is such a knowledge: Docker image represents a container file system content;

2 preliminary contact with the joint file systemThe concept of the joint file system, which makes me aware of the technology of image level management, is part of the contents of the container file system.

3 study the relationship between image and container: container is a dynamic environment, each layer image file belongs to static content, however Dockerfile in the env bike, volume, CMD and other content will eventually need to implement the operation of the environment of the container, and the content are not likely to lie directly to each layer image contains the contents of the file system, that part of the contents of this docker the how to manage?

In addition, in the above third steps, there is a situation, I believe we are not unfamiliar: a lot of the size of the mirror layer 0, the image layer does not exist within the contents of any file. This is how the same thing?

You can recall the "one figure to see the contents of the Docker container file system", the generation of the empty mirror, which refers to "update the image of the JSON file". In fact, the previous foreshadowing, hinting at the truth:Docker mirror contentMirror layer file contentandMirror JSON fileform, whether static or dynamic information, Docker are updated in the JSON file.

JSON each layer of the image of the Docker file, are playing a very important role, and its main role is as follows:

1 record the contents of the dynamic information of the container in the Docker image

2 record the true difference between father and son Docker image

3 make up the lack of the integrity and dynamic content of the Docker image content

Docker mirror JSON file can be considered to be a mirror of the metadata information, its importance is self-evident, this series will be in the next article focuses on the analysis of Docker image JSON file. Please look forward to.

Docker mirror storage location

Docker mirroring the content of theoretical analysis, look at how many somewhat foggy, whether docker mirror layers of the file, or JSON file, read to slightly boring. If you can see the real environment in Docker, I believe that the understanding of the mirror technology will have a lot of help.

We went straight to the theme, starting with the storage of Docker mirror, look at theseMirror layer file contentandMirror JSON fileWhere are stored in. (below shows the experimental environment: host operating system for ubuntu:14.04, Docker version for 1.7.1, graphdriver type for aufs, only contains ubuntu:14.04 a mirror).

View mirror layer composition

We can pass the orderHistory ubuntu:14.04 dockerView ubuntu:14.04, the results are as follows:
Write the picture here.

Figure shows a total of 4 ubuntu:14.04 mirror image layer.

Mirror layer file content storage

The content of the Docker mirror layer is generally in the aufs root directory of the Docker path, for the /var/lib/docker/aufs/diff/, the specific circumstances are as follows:
Write the picture here.

The diagram shows the contents of the 4 mirror images of the mirror ubuntu:14.04, as well as the contents of the first level directory within each image layer. Need to pay extra attention to: there is no content in the image layer d2a0ecffe6fa.

Mirror JSON file storage

For each mirror layer, Docker will save a copy of the corresponding JSON file, JSON file storage path for /var/lib/docker/graph, ubuntu:14.04 all the image layer of the JSON file storage path is shown as follows:
Write the picture here.

In addition to the JSON file, we also see that each mirror layer also contains a layersize file, the file is mainly to record the total size of the image layer inside the file content. Since it comes to the mirror image JSON file, in order to pave the way, the following posted ubuntu:14.04 hollow mirror layer JSON d2a0ecffe6fa file:
Write the picture here.

Because of the instructions for a layer of the image corresponding to the Dockerfile CMD, so mirror the content is empty, and mirror the JSON file will update the CMD domain, to obtain the value of the new CMD in order to follow the through the mirror the container operation, using the updated CMD.


Docker mirroring the essence of Federated file system. However, in addition, for image metadata management (i.e., mirror image JSON file) opened the mirror through docker directly run docker container shortcut.

Write the picture here.

Welcome attention[Docker source code analysisMicro channel public number, more exciting upcoming.

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
    • visit86219 times
    • Integral:One thousand three hundred and seventy-three
    • Grade
    • Rank:18305th name
    • original47
    • Reproduced:0
    • Translation:1
    • Comments:51
    Blog column
    contact information
    Latest comments