[Beginner] What is Docker in the first place? Easy-to-understand explanation from the basics!

Introduction

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).

What is Docker in the first place?

Docker is a "virtual environment construction tool".

What is a virtual environment?

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.

スクリーンショット 2020-11-15 18.17.42.png See: What is a virtual machine? Explain the basic knowledge and features of "virtualization" and "virtual machine" that you often hear

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.

Virtual machine type

There are several types of virtual machines. I will briefly explain the advantages and disadvantages of each.

① Host type ② Hypervisor type ③ Container type

image.png See: What is a virtual environment? Explanation of advantages and disadvantages, typical software "VMware"

① Host 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.

② Hypervisor type

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.

③ Container type

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.

What is Docker again? ??

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.

How Docker 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

What is a Docker engine?

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

What is a Docker container?

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

What is a Docker image?

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-docker

Summary

I 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

[Beginner] What is Docker in the first place? Easy-to-understand explanation from the basics!
What is the main method in Java?
What is CHECKSTYLE: OFF found in the Java source? Checkstyle to know from
What is Pullback doing in The Composable Architecture
What is JSP? ~ Let's know the basics of JSP !! ~
What is Docker?
What is Docker
What is Docker
What is ... (3 dots) found in the Java source? Variadic arguments to know from
Get the value from the array and find out what number it is included in
What is the LocalDateTime class? [Java beginner] -Date and time class-
What is the representation of domain knowledge in the [DDD] model?
What I did in the version upgrade from Ruby 2.5.2 to 2.7.1
[Summary of technical books] Summary of reading "Learn Docker from the basics"
[Understanding in 3 minutes] What is Ruby inheritance? Only the main points are explained in an easy-to-understand manner!
Why you need a bundle exec
Place in the middle with css
Have you stopped thinking about using getters / setters in DTO design patterns?
[Beginner] What is Docker in the first place? Easy-to-understand explanation from the basics!
The story of learning Java in the first programming
When you get lost in the class name
Why don't you include Vue.js in Docker's Laravel! !!
What is docker run -it?
Docker monitoring-explaining the basics of basics-
What is the pluck method?
Understand the basics of docker
This is the first post.
What is the BufferedReader class?
What is the constructor for?
[Java basics] What is Class?
What is the initialize method?
The repository ... is not signed error in docker build apt-get update
What I did in the migration from Spring Boot 1.4 series to 2.0 series
Install lsb_release from the command line when lsb_release fails in docker environment
What is @Override or @SuppressWarnings ("SleepWhileInLoop") in front of the function? ?? ??
What I did in the migration from Spring Boot 1.5 series to 2.0 series