Docker's Learning Notes
1. Docker was originally designed to solve any problems.
The advent of Docker is to originate from the PAAs project DotCloud. The main positioning of the pass project is to provide relevant facilities for software development: The language environment, the operating environment and the storage environment. When DotCloud on the LXC and go language development of the pass platform to do the extreme, theoretically dotcloud is not limited by the environment. Under some pressure in the background, the DotCloud team will open up its core engine (become Docker), which is sought after by the vast majority of developers.
As you know, the goal of the pass project is to provide the relevant facilities for the software development environment: the language environment, the operating environment and the storage environment. So Docker's features are quite clear: Docker claims that developers can compile, test, package their applications and rely on portable containers, and then publish them to any service and deploy them in a production environment. Docker is an open source engine that can create a lightweight, portable, self-contained container for any application.
The container is a full sandbox mechanism, with no interface to each other, and a bit like the standalone apps in iOS.
2. Learn about Docker's foothold in realizing its function.
We first understand what a container is. To understand the basic concept of a container, we first understand another basic concept of the container: the namespace (namespace), the context in which the identifier (identifier) is represented. An identifier can be defined in more than one namespace, and its meaning in different namespaces is mutually irrelevant. In this way, any identifiers can be defined in a new namespace, and they do not conflict with any existing identifiers because existing definitions are in other namespaces. Once we understand the namespace, we'll look at the container in more detail. A container is a new process. Tools like Docker and Rkt have been developed to allow us to systematically use these features. These tools provide packaged functionality to package a namespace into a container so that we can easily move it to another machine, and it will continue to run in exactly the same way as before, because of its isolation characteristics. In fact, it is often easy to imagine a container as a small computer that can run completely independently. Because these new tools are very easy to use, they are becoming a popular way to build software.
The process in the container. Here, a process can only interact with other processes and resources that reside within the same container.
Docker on the basis of the container, the further encapsulation, from the file system, network interconnection to process isolation, etc., greatly simplifies the creation and maintenance of containers. Makes Docker technology more portable and faster than virtual machine technology.
3. Know the basic concept of Docker.
Docker includes three basic conceptual image (image) containers (Container) warehouses (Repository)
By understanding these three concepts, you understand the entire life cycle of Docker.
A), mirror (image)
A mirror is a file system, similar to the root filesystem in Linux. In addition to providing the programs, libraries, resources, configuration, and other files required by the container to run, there are some configuration parameters (such as anonymous volumes, environment variables, users, etc.) that are prepared for the runtime. The image does not contain any dynamic data, and its contents are not changed after it is built.
When mirroring is built, a layer is built, and the previous layer is the foundation of the latter layer. Once each layer is built, no changes will occur, and any changes on the next level only occur on its own level. For example, the deletion of the previous layer of the file, actually not really delete the previous layer of the file, but only in the current layer marked as the file has been deleted. While the final container is running, you will not see this file, but in fact the file will always follow the image. Therefore, when you build the image, you need to be extra careful that each layer contains as little as possible what the layer needs to add, and any additional things should be cleaned up before the end of the layer is built.
b), container (container)
Mirroring (image) and container (Container) relationships, like classes and instances in object-oriented programming, mirrors are static definitions, and containers are entities that mirror the runtime. Containers can be created, started, stopped, deleted, paused, and so on.
When a container runs, it creates a storage layer of the current container on the mirror as the base layer, and we can call this storage layer that is prepared for the container runtime to read and write, as the container storage layer. If the Docker container needs to write the files in the underlying Docker image, then a mechanism called copy-on-write is involved, that is, the federated file system, such as AUFS, that first copies this file from the Docker mirror layer to the topmost writable layer. The container process then writes to the copy in the read-write layer. For a container process, it sees only the topmost file.
c), Warehouse (Dockerregistry)
Once the image has been built, it can be easily run on the current host, but if you need to use this image on a different server, we need a centralized storage and distribution of mirrored services, Dockerregistry.
A Docker Registry can contain multiple warehouses (Repository), each warehouse can contain multiple tags (tag), and each label corresponds to a mirror. Typically, a warehouse contains a different version of the same software image, and the label is often used for each version of the software. We can specify which version of this software is mirrored by < warehouse name >:< tag > format. If the label is not given, latest is used as the default label. As an example of Ubuntu image, Ubuntu is the name of the repository with different version tags, such as, 14.04, 16.04. We can specify which version of the image is required by ubuntu:14.04, or ubuntu:16.04. If you omit the label, such as Ubuntu, it will be considered ubuntu:latest.
Article reference:
Https://github.com/bingohuang/play-docker-images
Https://github.com/yeasy/docker_practice/blob/master/SUMMARY.md