File system changes for Docker file system and boot container

Source: Internet
Author: User
Tags diff docker toolbox
This is a creation in Article, where the information may have evolved or changed.

This article mainly introduces the Docker basics, first introduce my implementation environment:
1. Windows 10 Official edition
1. Docker Toolbox
1. Docker version 1.8.2
1. Official Image Ubuntu:latest

Here we mainly only say aufs/containers/graph these three directories.

1. Enter the Docker file system directory First

Ll/var/lib/docker #其中目录是这样的/var/lib/docker-/mnt/sda1/var/lib/docker/df-h # View mount status filesystem Size         Used Available use% mounted ONTMPFS 896.6M 115.3M 781.3M 13%/tmpfs 498.1M                  0 498.1M 0%/dev/shm/dev/sda1 18.2G 300.1M 16.9G 2%/mnt/sda1cgroup                498.1M 0 498.1M 0%/sys/fs/cgroupnone 100.0G 42.1G 57.9G 42%/c/users/dev/sda1 18.2G 300.1M 16.9G 2%/mnt/sda1/var/lib/docker/aufsls-l/mnt/sda1/var/lib/docker/drwxr-xr-x 5 ro  OT root 4096 Sep 01:59 aufs/# System mount directory, System use AUFSDRWX------2 root root 4096 Oct 7    03:48 containers/# Container File system drwx------7 root root 12288 Oct 7 03:48 graph/# local Mirror-rw-r--r-- 1 root root 15360 Oct 7 03:48 linkgraph.db-rw-------1 root root the Oct 7 03:48 reposit ORIES-AUFS # Stores image-relatedBasic information drwx------2 root root 4096 Oct 7 02:52 tmp/drwx------2 root root 4096 Sep 28 02:01 trust/drwx------2 root root 4096 Sep 01:59 volumes/

Take a look at my local image

docker images REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZEubuntu              latest              91e54dfb1179        6 weeks ago         188.4 MB

I have a local ubuntu:latest office image, and the short ID of image is 91e54dfb1179. This shows that the image of Docker is made up of mirrored layer file contents and JSON files.
1. Mirrored layer files are stored in /var/lib/docker/aufs/diff
1. The JSON file for the local image is stored in the /var/lib/docker/graph folder.

As shown in, the mirrored JSON file stores the mirrored metadata, such as the parent image ID

The /var/lib/docker/aufs/layers image ID and hierarchy are stored, for example, we know that the image ID at the bottom isd3a1f33e8a5a513092f01bb7eb1c2abf4d711e5105390a3fe1ae2248cfde1391

We view container-level content

$ cd /var/lib/docker/aufs/diff/d3a1f33e8a5a513092f01bb7eb1c2abf4d711e5105390a3fe1ae2248cfde1391$ ls

We see the Rootfs file directory as shown, and this image as the root of the Images, we use the final image ubuntu:latest is on the basis of this image based on the relationship between the layers dynamically added.

For example, /var/lib/docker/graph under the image ID and the mirrored JSON, view the contents of the JSON file as:

All metadata such as the ID of the parent image, the command executed on the parent mirror ID, and the generated image ID are included as shown. When we start the container, we add it gradually and incrementally from top to back rootfs .

2. Start the container

When we run the upper command, the basic process is as follows:
1. It will first check if we have a local ubuntu:latest image, if it exists, load the image, which we mentioned earlier 91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e267c .
2. Create a container, the program CreateRootfs will call the Create function mnt to diff create folders under the and folder ID-init , and then through the program's function to the GET dependent layers layer according to the hierarchical relationship of loading into the ID-init folder. Only ID-init is writable, others are readable.
3. Call the Create function again to create the folder ID , create the folder containers and all the configuration files under the folder, and ID then start the container, and then mount the layer of the dependent container to the folder in turn ID .

When we operate within the container, the /var/lib/docker/containers/ID/ID-json.log log is stored in, as

, we can see from the log that we have two operations on the container:

cd roottouch 1.txt

Then we create a 1.txt file, which is recorded /var/lib/docker/diff/ID/root/ under, as

This makes it easy to see the hierarchical relationships and data relationships of Docker.

Today is the point here, where do not understand or the article is wrong, please send an email to admin#widuu.com (#换成 @)

Without permission, do not reprint this site any article: Micro network»docker file system and boot container file system changes

Related Article

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.