An empty question is often not necessarily a bad one. Although I have been using docker for some time, on the first day of the month, let me answer the difference between docker and ordinary virtual machines, but I haven’t really studied it carefully. With this question in mind, I searched and probably understood some truth. Let me try to give a simple answer as follows:
Docker uses the container technology based on the Linux operating system itself. The container technology differs from the virtual machine in that the container is simply isolated and does not provide very low-level operating system functions. Therefore, the system in Docker must be exactly the same as or similar to the operating system of the host computer. It can be a Linux system and cannot run Windows Docker on the Linux system. You can have a look at the brief introduction of LXC.This article(Docker later switched to runC, but the principle is similar). Generally speaking, this is the case, but with Docker’s market share increasing, manufacturers are gradually thinking about whether they can run different operating systems on different operating systems. For example, the first is Docker, which runs Linux on Windows? This can already be done at present, and if the Docker running Windows on Linux is also under development, so everything is not absolute.
What are the benefits of container technology based on host operating system? Suppose you have an operating system that takes up 1G of hard disk space. If you use virtual machines, you need 100G of hard disk space to build 100 such virtual machines. If you use Docker, 1000 containers will only take up a little more space than 1G. Of course, suppose these 1000 containers all use the same operating system. So do you see the difference? In other words, if you need strictly isolated operating systems, then you need to use virtual machines, but if you don’t care whether the underlying operating systems are isolated, as long as they can be used, then you can use Docker, because for Docker, the underlying operating system files are shared and do not take up space.
In addition to occupying no space, Docker’s startup speed is also on the order of seconds, even less than one second. If you want to start a virtual machine, it is equivalent to starting a complete set of operating systems, so the starting speed will be slower, but Docker’s starting speed is quite fast.
At the same time, in Docker, you can also make your own image based on the original operating system image. Assuming that the original operating system image you downloaded is 1G, and you have made some changes on the basis of it and added 50M content, then the new image you made based on it is not 1G+50M, but 50M, because the bottom layer of Docker helps you to do isolation, and your image file only occupies the incremental part of space. However, if you rebuild a new virtual machine based on the virtual machine, the hard disk space will at least double.
The above is probably the difference between Docker and virtual machine, and the specific use should be analyzed on a case-by-case basis.