Linux install Docker and run Ubuntu system

Linux install Docker and run Ubuntu system

Docker is a kind of container, what is a container? In software development, we often encounter "This program is obviously no problem on my computer, why is there a problem on the customer's computer?" This is because the software and hardware of each computer are inconsistent.

Is there a unified, virtual software and hardware platform on which the software is developed and sent to customers, who can directly run programs on this platform? Yes, this is the container. There are many kinds of containers, and Docker is the better one.
Compared with VMware, Docker is a lightweight software that runs fast.

Before using Docker, you need to understand two concepts: Image and container, that is, image and container. The image is an environment package, which can be moved to any Docker platform to run. The container is an instance of an image, and one image can start multiple containers.
In a simple analogy, the image is like a Word software, which is released by the manufacturer and you cannot modify it; the container is when you start the Word software, you can start multiple Word software, and write different documents in each Word software.

The core of Docker is the "union file system". What does it mean?
Suppose you have two directories: lower and upper, they can be merged into a new directory merged, the content is as follows:
Insert picture description here
What is the principle of merging? The upper directory has higher priority and can overwrite the lower directory. The lower directory is read-only, and the upper directory is readable and writable. This rule can be parsed more specifically:

① If the file name and directory are different, the files and directories in the lower and upper directories are merged into the merged directory according to the original structure;

② With the same file name, only files in the upper layer are displayed:
as shown in the figure above, there are the same.txt files in the lower and upper directories and in the lower directory dir_A, but when merged into the merged directory, only upper files are displayed, and lower is hidden .

③ If the directory name is the same, merge the directories into one directory:
as shown in the above figure, there are dir_A directories in the lower and upper directories. Merge all the files in the directory and the directory into the merged dir_A directory. If there are files with the same name in the directory, then Also only display upper, as the same.txt file in the dir_A directory in the above figure.

When reading a file, if there is the file in the upper directory, read it from the upper directory; otherwise, read it in the lower directory.
When creating, modifying, or deleting files, only the upper directory is affected, and the lower directory is read-only and is not affected.
In Docker, the image provides read-only files in the lower layer; the container provides readable and writable files in the upper layer, as follows:
Insert picture description here
When we start a container, we create a readable and writable file based on the lower file system provided by the image. Upper layer file system written.
We can start multiple containers, that is, create multiple upper layer file systems, and the upper layer file systems of these containers do not affect each other.

We provide the image file with various software installed; all you need to do is download the image, start the container, download your program in the container, and compile them.

Reference article: Linux overlay file system analysis
Full text download: Embedded Linux System Development Complete Manual Second Edition

Guess you like

Origin blog.csdn.net/thisway_diy/article/details/107137742
Recommended