Docker line learning


Several blog before, take some docker knowledge (although you can directly get started), but for those who do not docker is based do not know why to do so.

I took the step before learning docker sorted out, we hope to help more people to learn docker.

table of Contents:

1. Docker basis

1.1 Docker history

1.2 Docker part

1.3 Docker core concepts

1.4 Docker command

    1.5 Dockerfile

2. CI (continuous integration) 2.1 Jenkins 3. CD (continuous deployment) 3.1 Mesos 3.2 Kubernetes (K8S) 4. Service Discovery 4.1 etcd 4.2 SkyDNS 4.3 Consul 5. Management Platform

6. Summary

A, Docker basis

1. Docker history

Excerpt from “Docker Development Guide”

Shipping metaphor     Docker's philosophy is often used analogy to explain the shipping container, which may explain the origin of the name of Docker.     The metaphor is probably the case. When the transport of goods, to use a variety of different means of transport, which may include trucks, forklifts, cranes, trains and ships. This means that these tools must be able to handle different sizes and the demand for transport of goods (such as bags of coffee, barrels of toxic chemicals, boxed electronic products, into the team's limousine, frozen lamb chops). In the past this is a complicated and costly process, it will take a lot of manpower and material resources. As shown in FIG 1-3, the manual loading and unloading dock workers at each transfer station.     The birth of intermodal containers for the transport industry has brought a revolution. The size of the container with uniform standards, and design is the starting point with a minimum of manual handling between different modes of transport. All transport machinery, forklifts and cranes both, or trucks, trains and ships, carrying these containers are designed. Transport of temperature sensitive goods (e.g., food and drugs), the container may be used with refrigeration and insulation function. The benefits of standardization even extended to other support systems, such as labels and seals the way containers. Therefore, the transportation industry just focus on handling and storage problems handling the container itself, but something inside the container is entirely the responsibility of the producer of the goods.     Docker's goal is to be applied to containers of standardized processes to the IT industry. In recent years, the surge in the diversity of software systems. LAMP4 run combined in a single machine Gone are the days. Now, the typical system may contain JavaScript framework, the NoSQL databases, message queues, REST API, and a rear end from a variety of different programming languages ​​written. The combination of all or part of this need to be able to run on a variety of hardware - from the developer's laptop, to test cluster within the company, to the cloud production environment. There are differences in each environment, they are running a different operating systems and different versions of the libraries on different hardware. In short, our problem was very similar to the transportation industry experience - we are constantly pay a huge human, to move the program between different environments. Docker container simplifies the work of mobile applications, such as intermodal container simplifies the transport of goods. Developers only need to focus on program development, no longer have to worry about the difference between the test and released the environment and dependence brings. Operation and maintenance department simply concentrate on container processing related to the operation of the core issues, such as the allocation of resources, start and stop the container, as well as migration between servers.

docker (originally referred to the ship after docking in the port of goods into or out of workers) content of the work (a picture is worth a thousand words, taken from the “Docker Practice”)


After reading the above description, go read the official description for Docker’s, it would be easier to understand.

Official description: View

Personal understanding:

Docker can be understood as a container (of course, is essentially a software), it will depend on the application (to be published in the website program files) and application packaging, deployment in any environment (servers, cloud, etc.).

1.2 Docker part

Docker logically consists of three parts: Daemon (daemon), Rest API (API, all clients operated by API), Client (client)



Official description: View

1.3 Docker core concepts

Core concepts: layer, the mirror, the container.

The relationship between the three:

Layer can be understood as a collection of files, mirroring it consists of different layers (only the top layer can be written, other layers are read-only)




The relationship between the mirror and the container:

Personal understanding:

Object-oriented manner understood that: the mirror can be compared to the class, the container can be compared to the object (a specific instance) as a class, want to remove the mirror, all the containers need to stop and remove the Mirror operation.

Further reading:

docker underlying technology: cgroups (Resources is responsible for managing the use of containers, such as CPU, memory), Namespaces (isolation between responsible container), UFS (Union File System, a joint file system)

If you want in-depth understanding of the principles docker, you can look at the UFS principle.

1.4 Docker command

Official description: View

for example:

Search Mirror: Mirror docker search to search

docker search redis

Download Mirror: doucker pull to the downloaded image: label (if you do not write, the default is latest)

docker pull redis:latest

Run containers: docker run Redis parameter (image name), reference may be specific parameters represents a meaning (see)

docker run -d -p 6379:6379 --restart=on-failure:10 --name myredis redis 

Docker command can be divided into the following categories:

run command, image information, image management, container information, container management, information Docker

Description: What are the specific classification of each command, you can view the summary of the final article

1.5 Dockerfile

Dockerfile generally used to create a mirror image, the specific use please see

Official description: View


Docker Compose, before Docker Machine has been writing articles explained, there is no longer described.

Official website: View command to view the Machine Compose command

Two, CI (continuous integration)

Jenkins is the most popular continuous integration tool. Jenkins can use docker be published.

Jenkins use docker installation procedure, review. Execute the following command can also directly download the image and run container

docker run -d -p 8090:8080 -p 50000:50000 -v jenkins:/var/jenkins_home -v /etc/localtime:/etc/localtime --name myjenkins

Then enter in the browser http: // *: 8090 (* as a docker where the host ip address), as shown below:

The password can be viewed through the following command

#myredis 是容器的名称(docker run命令的--name参数)
docker logs myredis



Copy and paste the password into the input box, and then click “Continue”, then the configuration can Jenkins (it is very convenient).

Three, CD (continuous deployment)

3.1 Mesos

Official website: View

Currently there are a number of companies are using, you can find out.

3.2 Kubernetes(K8S)

Net official document: View

Currently learning. . .

Fourth, service discovery

4.1 etcd

etcd consistency is a distributed key-value storage system for sharing configuration and service discovery.

Use: View

4.2 SkyDNS

Official website: View

4.3 Consul

Consul function contains three main parts: service configuration (similar to etcd and zookeeper), service discovery (similar SkyDNS), service monitoring.

Use description: View

Fifth, management platform

Used several platforms (DockerUI, Portainer, Rancher, etc.), there was still Portainer better use some.

Portainer official website: View

Use the following command to download and run a container

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --name myportainer

Visit the following address: http: // *: 9000 (* ip address docker is where the host)




VI Summary

I study the road map, as shown below (from left to right).

Learning: Intensive (basic knowledge), Extensive Reading (related knowledge)



Leave a Reply