It's a little late, but I've learned about Docker from the basics, so I'll summarize it. The detailed options of all commands are not summarized. The purpose of this article is to get to know a tool called Docker, which is rudimentary (but important).
Docker is a "virtual environment construction tool".
A virtual environment is a temporary space (a place to realize something) that is artificially created in a computer. If you chew a little more, it is an environment where you can move what you originally need physically as if it were virtual.
For example, in a Windows environment, a virtually created Linux OS environment or another Windows OS environment can be prepared as an example of a virtual environment. Generally, the OS that forms the basis of creating a virtual environment is called the "host OS", and the OS on the virtual environment is called the "guest OS". By building a virtual environment, it is no longer necessary to physically prepare a personal computer for Linux and a personal computer for Windows, and it becomes possible to centrally manage with one hardware. It also has the advantage of being able to flexibly adjust the memory and hard disk capacity. Building a virtual environment also saves hardware equipment.
There are several types of virtual machines. I will briefly explain the advantages and disadvantages of each.
① Host type ② Hypervisor type ③ Container type
This type installs a host OS on a personal computer or server, and installs and builds virtual environment creation software on that OS. The guest OS is lined up on top of the host OS.
-Advantage: You can use it immediately by installing it on an existing server, and you can start it easily. -Disadvantage: The host OS must be started. When the hardware is booted, it may take some time for the host OS to boot.
The type that builds virtualization by directly installing virtualization software called "hypervisor" on one piece of hardware is the hypervisor type. Since it is not necessary to start the host OS, it can be started faster than the host OS type.
-Advantage: Since there is no host OS, most of the resources can be allocated to the virtual environment. -Disadvantage: You have to purchase new hardware without reusing existing PCs and servers. When building, you also need to pay attention to the cost aspect.
Virtualization software called "container engine" is installed in the host OS, an environment called a container is created in it, and applications are executed. Containers do not have the concept of a guest operating system. It is recognized as one process by the host OS. Therefore, no extra resources are required and a light environment can be provided. When you actually use it, you will be able to start the application in a short time.
-Advantages: Good resource efficiency and excellent cost performance. ・ Disadvantage: There are few vendors that can be built because it is a new technology. There is a lack of convenient management tools.
As mentioned above, Docker is a "virtual environment construction tool". Among them, you can build a virtual environment called "** container **" and run applications, middleware, OS, etc. in that container. One of the attractions of the container is that it is extremely lightweight and can be started and stopped quickly. Let's see how Docker actually works.
Here, we will deepen our understanding of how Docker works, based on terms that Docker beginners should keep in mind.
・ Docker engine ・ Docker container ・ Docker image
The Docker engine can be understood as "Docker itself". This is the core part of Docker that creates Docker images and starts containers. This Docker engine can be easily used by installing Docker on the host OS (Windows, Mac, Linux). After installing, it feels like the Docker engine is running on the host OS and each container is running on it.
<img src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/623708/c6cdea87-5c94-5188-cbf6-b0112bcd0f1e.png ", width="500">
See image: https://www.ogis-ri.co.jp/otc/hiroba/technical/docker/part1.html
A Docker container is a virtual environment running on the Docker engine. With the Docker container, you can create various environments from OS such as CentOS and Ubuntu to middleware such as Nginx and MySQL, and applications such as Rails and Wordpress. These containers are characterized by "** running using the host OS kernel (Linux kernel) **"! The Linux kernel is the core software that collects the basic functions required for the OS.
The question here is, "** Will Docker start up on Windows and Mac without Linux? **". The answer stands up! The reason is that the Linux virtual machine runs behind the start of Docker, so each container also runs on this virtual machine.
Also, this virtual machine, Linux, is not independent for each container, but the one that is common to all containers is used, so it operates while saving the resources (CPU and memory) of the host machine. Doing so ** makes the container itself lighter, and above all, the reason why Docker containers start up faster **.
<img src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/623708/2c9da8b1-609f-20e5-6484-84624142df97.png ", width="500">
See also: https://kitsune.blog/docker-summary#Docker%25E3%2582%25B3%25E3%2583%25B3%25E3%2583%2586%25E3%2583%258A%25E3%2581%25A8%25E3%2581% 25AF
A Docker image is like a ** manual ** for creating a Docker container. A container is created based on this Docker image. You can create a new image by superimposing a "layer" on each image, which is the "base image" that is the original image!
See image: https://dzone.com/articles/optimizing-spring-boot-application-for-dockerI have briefly summarized about Docker and how Docker works. Even if you can understand the outline of Docker, if you do not have basic knowledge of Linux, you will be stuck with Docker environment settings, so I would like to study Linux as well.
Recommended Posts