1、Overview and 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

1.1、Docker overview

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.

1.1.1、why docker appears

Let's start with a few scenarios:

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

  2. The project to be launched is unavailable due to the update of some software versions...

  3. 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!

1.1.2、Docker's core idea

 

image-20230424111123951

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.

1.1.3、Compare virtual machines to Docker

 

1.1.4、docker architecture

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.

30f24e4195234f58afbe43525dd57504

 

1.1.5、Docker core objects

 

1.1.6、images, containers, repositories

Image:

Container:

Repository:

You need to correctly understand the concepts of warehousing/image/container:

1.1.7、Docker operation mechanism

Docker pull execution process:

  1. The client sends instructions to Docker Daemon

  2. Docker Daemon first check whether there are relevant images in the local images

  3. If there is no relevant image locally, request the mirror server to download the remote mirror to the local computer

docker run execution process:

  1. Check whether the specified image exists locally and download it from the public repository

  2. Create and start a container from the image

  3. Assign a file system (lite Linux system) and mount a read-write layer outside the read-only image layer

  4. Bridge a virtual interface from the bridge interface configured by the host to the container

  5. Configure an IP address from the address pool to the container

  6. Execute the application specified by the user

1.2、docker installation

  1. Official website installation reference manual: https://docs.docker.com/engine/install/ubuntu/

  2. You can use the following commands to install with one click:

  1. Check the docker version

image-20230424113920974

  1. Test the command

The following output indicates that the Docker installation was successful

image-20230424113848585