1、Overview and installation1.1、Docker overview1.1.1、why docker appears1.1.2、Docker's core idea1.1.3、Compare virtual machines to Docker1.1.4、docker architecture1.1.5、Docker core objects1.1.6、images, containers, repositories1.1.7、Docker operation mechanism1.2、docker installation
Docker Chinese website: https://www.docker-cn.com
Docker Hub (repository) official website: https://hub.docker.com
Docker official website: http://www.docker.com
Docker is an application container engine project, developed based on the Go language and open source.
At present, ROS2's courses are all placed in Docker containers, and customers can experience learning to use containerized development methods.
Let's start with a few scenarios:
O&M deploys the project you developed to the server, telling you that there is a problem and cannot be started. You ran around locally and found that there was no problem...
The project to be launched is unavailable due to the update of some software versions...
There are a lot of environmental content involved in the project, various middleware, various configurations, and the deployment of multiple servers...
These problems can actually be summed up in relation to the environment. To avoid various problems caused by different environments, it is best to deploy the project together with the various environments required by the project. For example, the project involves environments such as REDIS, MYSQL, JDK, ES, etc., and the entire environment is brought with you when deploying the JAR package. So the question is, how can you bring the project with the environment?
Docker is here to solve this problem!

This is the logo of Docker, a whale full of containers, on the back of the whale, the containers are isolated from each other, which is the core idea of Docker. For example, if there were multiple applications running on the same server before, there may be port occupation conflicts of software, but now they can run alone after isolation. In addition, Docker can maximize the power of the server.

The docker daemon can communicate directly with the main operating system to allocate resources to individual docker containers; It can also isolate containers from the main operating system and isolate individual containers from each other. Virtual machines take minutes to start, while docker containers can start in milliseconds. Since there is no bloated from the operating system, Docker can save a lot of disk space as well as other system resources.
Virtual machines are better at completely isolating the entire operating environment. For example, cloud service providers often use virtual machine technology to isolate different users. Docker is often used to isolate different applications, such as front-end, back-end, and database.
Docker containers are more resource-efficient and faster (start, shut down, create, delete) than virtual machines
Docker uses a client-server architecture. The Docker client communicates with the Docker daemon, which is responsible for building, running, and distributing the Docker container. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The docker client and daemon communicate using REST APIs over UNIX sockets or network interfaces. Another Docker client is Docker Compose, which lets you work with applications that consist of a set of containers.

docker client is a docker command that is used directly after installing docker.
Docker host is our docker host (i.e. the operating system on which docker is installed)
Docker Daemon is Docker's background daemon that listens for and processes Docker client commands and manages Docker objects such as images, containers, networks, and volumes.
registry is a remote repository where docker pulls images, providing a large number of images for download, and saving them in images (local image repository) after downloading.
Images is a local image repository of docker, and image files can be viewed through docker images.

Image:
xxxxxxxxxxA docker image is a read-only template. Images can be used to create docker containers, and one image can create many containers. Just like classes and objects in Java, classes are images and containers are objects.
Container:
xxxxxxxxxxDocker uses containers to run independently of an application or set of applications. A container is a running instance created from an image. It can be started, started, stopped, removed. Each container is an isolated platform for security. Think of a container as a simple version of the Linux environment (including root privileges, process space, user space, network space, etc.) and the applications running in it. The definition of a container is almost identical to an image, and it is also a unified view of a bunch of layers, the only difference is that the top layer of the container is readable and writable.
Repository:
xxxxxxxxxxA repository is a place where image files are stored centrally. Repositories are divided into two forms: public repositories and private repositories.The largest public repository is Docker Hub (https://hub.docker.com/), which houses a huge number of images for users to download. Domestic public warehouses include Alibaba Cloud, NetEase Cloud, etc.
You need to correctly understand the concepts of warehousing/image/container:
Docker itself is a container runtime carrier, or management engine. We package the application and configuration dependencies to form a shippable runtime environment, and this packaged runtime environment is like an image image file. Only this image file can generate a docker container. An image file can be thought of as a template for a container. Docker generates an instance of the container from the image file. The same image file allows you to generate multiple container instances running at the same time.
The container instance generated by the image file is itself a file, called an image file.
A container runs a service, and when we need it, we can create a corresponding running instance through the docker client, which is our container.
As for the repository, it is a place where a bunch of images are placed, we can publish the images to the repository, and pull them from the repository when needed.
Docker pull execution process:
The client sends instructions to Docker Daemon
Docker Daemon first check whether there are relevant images in the local images
If there is no relevant image locally, request the mirror server to download the remote mirror to the local computer
docker run execution process:
Check whether the specified image exists locally and download it from the public repository
Create and start a container from the image
Assign a file system (lite Linux system) and mount a read-write layer outside the read-only image layer
Bridge a virtual interface from the bridge interface configured by the host to the container
Configure an IP address from the address pool to the container
Execute the application specified by the user
Official website installation reference manual: https://docs.docker.com/engine/install/ubuntu/
You can use the following commands to install with one click:
xxxxxxxxxxcurl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
Check the docker version
xxxxxxxxxxsudo docker version
Test the command
xxxxxxxxxxsudo docker run hello-world
The following output indicates that the Docker installation was successful