(1) Briefly explain what Docker is and the Docker installation tutorial

1. What is Docker?

Before using docker, we should first clarify what kind of problem docker exists to solve.

1. Deploy your application on another computer

For example, if you write a web application, you can debug it locally without any problem. However, if you want to deploy this web application to a remote server, or send a message to your friend, first of all, another computer wants to run your For web applications, the other computer needs to be configured such as database, web server, necessary plug-ins, operating environment, etc., and there is no guarantee that the software can run completely. Even if the same operating system is configured, it will be caused by version problems. web application not working

[External link image transfer failed, the source site may have anti-leech mechanism, it is recommended to save the image and upload it directly (img-oxtv7yoP-1643300290404) (Docker note/1642833074105.png)]

To solve this problem and make the application run normally on another computer, we need to simulate the same running environment as our local. At this time, we may think of virtual machines, but virtual machines must not only simulate software, but also Simulate hardware, run the entire operating system, the memory usage is high, and the program performance will also be affected, which is very bloated

2. Docker solves the deployment problem

At this time, docker comes in handy,

Docker is very similar in concept to virtual machines, but it is much more lightweight and flexible. Docker does not simulate the underlying hardware, but only provides a completely isolated operating environment for each application . We can configure the configuration in each environment . Different tools and software, and each environment does not affect each other at all, and this environment, in docker, is also called a container .

[External link image transfer failed, the source site may have an anti-leech mechanism, it is recommended to save the image and upload it directly (img-us0b9EQh-1643300290407) (Docker note/1642833767935.png)]

2. Three important concepts in Docker

1. Image / Mirror

You can think of an image as a snapshot of a virtual machine that contains your application and all the libraries it needs to run

[External link image transfer failed, the source site may have anti-leech mechanism, it is recommended to save the image and upload it directly (img-m2lKeHmO-1643300290408) (Docker note/1642834000359.png)]

2, Container / Container

Through mirroring, we can create many different containers . The containers here are like running virtual machines, which run your application, and each container runs independently.

[External link image transfer failed, the source site may have anti-leech mechanism, it is recommended to save the image and upload it directly (img-Xzrlt6Xb-1643300290409) (Docker note/1642834180690.png)]

The image is like the installation package of your app. You can install many software through this installation package. Each software is a container. They run independently and do not interfere with each other.

3、Dockerfile

Dockerfile is an automated script. It is mainly used to create our image. This process is like installing an operating system and software in a virtual machine. Dockerfile creates an image and configures applications in the image through a script. and operating environment

4. Registry / Warehouse

We can upload our own image to a remote repository, Docker Hub , you should know what this is doing by listening to the name, it is similar to github, but GitHub is to save our code, and Docker Hub is to save our image

3. Docker installation

1. Check the Linux version

Docker requires a kernel above 3.10

uname -r

[External link image transfer failed, the source site may have anti-leech mechanism, it is recommended to save the image and upload it directly (img-pcXywNNC-1643300290409) (Docker note/1642835157561.png)]

2. Uninstall the old version of docker

If you have not installed docker before, you can skip this step

          sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

3. Install and download the tools that Docker depends on

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

4. Add the software source of Alibaba Cloud

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

5. Update the yum cache (in order to ensure that the required services can be updated and downloaded: such as docker)

sudo yum makecache timer

6. Start installing Docker

sudo yum -y install docker-ce

7. Start docker

sudo systemctl start docker

7.1 If an error is reported

(1) View installed packages:

		yum list installed | grep docker 

[External link image transfer failed, the source site may have anti-leech mechanism, it is recommended to save the image and upload it directly (img-nS9z1IyR-1643300290410) (Docker note/1642837065992.png)]

(2) Delete the installed Docker-related packages:

	yum -y remove docker.x86_64

​       yum -y remove docker-client.x86_64

​       yum -y remove docker-common.x86_64

[External link image transfer failed, the origin site may have anti-leech mechanism, it is recommended to save the image and upload it directly (img-d12EjaqK-1643300290411) (Docker note/1642837083652.png)]

8. Check if Docker is successful

docker info

9. Self-start at boot

sudo systemctl enable docker

Guess you like

Origin blog.csdn.net/qq_45171957/article/details/122725563