Docker, I’ve heard about it for a long time, but it’s vague and vaguely understood. I’m trying to figure it out at the end of the year with less pressure. Do not understand to check the data to figure out, others have been chi chi chi use, and we do not know that is what east east, this is to die. That’s what I do. I die too long. Too bad you can’t live twice.

The following is my current understanding, may not be correct and comprehensive, but there must be learning output, first recorded, and then can start from here.

Docker is a container in which items can run. Containers have boundaries. Docker is isolated from the external environment, including the host machine and other containers, so as to provide a quiet and harmonious environment for the software running in it. It’s kind of like a virtual machine.

Second, what can be used to conveniently and quickly deploy software. Software can be easily and quickly deployed on different machines and operating systems. Because the software runs on Docker, docker shields the differences and details of the outside world. Therefore, for our software, the operating environment in the development stage and deployment stage is the same, which can be seamlessly grafted.

Third, why use feeling virtual machine is almost the same function, then what is the advantage of using Docker? 1. The granularity of resource-consuming small virtual machines is “virtual machines”, while the granularity of Docker is “restricted applications”. Comparatively speaking, Docker occupies less memory and is more lightweight.

We have 16 servers online, and if I tried to configure 512 MB per instance locally with VirtualBox, it would take up twice as much memory as my laptop (meaning his laptop only has 4 gb), and VirtualBox would have a lot of extra overhead to manage each sub-os. Docker is different in this respect — containers share the same operating system, more likely the same binaries and libraries, and it can run hundreds of containers on a single Docker host.

Thus, it is inappropriate to compare Docker with virtual machines. Docker is more like a simple process running on the host machine, it directly uses the things of the host environment; A virtual machine is a complete machine, albeit a virtual one.

2, fast startup time difference of an order of magnitude, virtual machine: minute level; Docker: second grade.

Both in terms of startup time and startup resource cost. Docker directly uses the system kernel of the host computer to avoid the system boot time and operating system resource consumption required by virtual machine startup. Docker can launch a large number of containers in a matter of seconds, something a virtual machine cannot do.

3. Low deployment cost It takes several days to introduce new hardware resources before a virtual machine. However, it still takes a long time to install a VM. Docker virtualization reduces this time to minutes. Docker simply creates a container process without booting the operating system, a process that takes seconds.

All kinds of famous software provide support for Docker. There are corresponding image files, which can be downloaded from the official website and directly handed to Docker to mount and run. To use the mysql database, you no longer need to install mysql. If the virtual machine, or to install mysql.

4. Improve development efficiency. Virtual machines run the same software based on different hardware facilities. Docker is a configuration that automatically ADAPTS to different hardware facilities (the operating environment and configuration are placed in code and then deployed), and then runs the same software, thus reducing the coupling degree between hardware requirements and application environment. Mom no longer worries about the “it works on my machine” phenomenon.

1. Resource isolation is not as good as virtual machines. Docker uses Cgroup to realize resource restriction, so it can only limit the maximum resource consumption, but cannot isolate other programs from occupying its resources.

2. Security issues. Docker cannot distinguish the specific user executing instructions at present. As long as a user has the permission to execute docker, he can perform all operations on the Docker container, regardless of whether the container is created by the user. For example, both A and B have the permission to execute docker. Since the Docker server does not know which user initiated Docker cline, A can delete the container created by B, which poses A certain security risk.

3. Docker is still in the rapid update of the version, and the details and functions are greatly adjusted. Some core modules rely on older kernels and have version compatibility issues

Docker is a LINUX container that only runs on LINUX. Windows can be installed, of course, but it’s still Linux at heart.

5, how to use the previous mentioned, using the image, you can not install software, direct docker mount operation. So I guess, with Docker to deploy, is such two steps: 1, make image file 2, Docker run image, generate instance

Generate instance, do not consume any time, time is in the production of mirror. How do I make this image? I don’t know yet.

Second, Docker claims that a single image can easily deploy hundreds of instances. If it is a mysql mirror, where is the data stored while the instance is running? Is it a container? Virtual machine has corresponding files, everything inside, is persisted in some files, docker is the same?

For your information, when the Docker instance is stopped and released, the data is gone. This is ridiculous. How to persist? The answer is to mount files from the host machine into the container. Use MySQL in Docker