Microservice—-Docker

1. Introduction

1.1 How does Docker solve the compatibility issues of complex dependencies and dependencies of different components in large projects?

Docker allows applications, dependencies, function libraries, and configurations to be packaged together during development to form a portable image.
Docker applications run in containers and are isolated from each other using a sandbox mechanism.

1.2 How Docker solves the problem of differences between development, testing and production environments

The Docker image contains a complete operating environment, including system function libraries, and only relies on the system's Linux kernel, so it can run on any Linux operating system.

1.3 The difference between Docker and virtual machines

Docker implements running and deployment on different Linux operating systems
  • Docker is a system process; the virtual machine is the operating system in the operating system

  • Docker is small in size, fast in startup, and has good performance; virtual machines are large in size, slow in startup, and have average performance.

    1.4 Docker Architecture

    Image: Docker packages the application and its required dependencies, function libraries, environment, configuration and other files together to become an image (that is, a file on the hard disk)

    Container: The process formed after running the application in the image is the container, but Docker will isolate the container and not be visible to the outside world.

    The container can read data from the image, but cannot write

    How will the MYSQL container write data in the future?

    Copy the data to its own independent file system, and write the data to its own place (the same principle applies to logs, and the mirror will not be disturbed or affected)

DockerHub: DockerHub is a hosting platform for Docker images. This platform is called Docker Registry

Docker is a CS architecture program, consisting of two parts

  • Server: Docker daemon, responsible for processing Docker instructions, managing images, containers, etc.
  • Client: Send instructions to the Docker server through commands or RestAPI. Instructions can be sent to the server locally or remotely

1.5 Summary

Docker is a technology for quickly delivering and running applications:

  • The program, its dependencies, and the operating environment can be packaged into an image, which can be migrated to any Linux operating system
  • The sandbox mechanism is used to form an isolated container during runtime, so that each application does not interfere with each other.
  • Startup and removal can be completed with one line of commands, which is convenient and fast

2. Docker installation (Windows version)

2.1 Preparing the environment

As for why I use the Windows version, I think using a virtual machine is too troublesome, and downloading the virtual machine to install various systems takes up a lot of space. More importantly, my virtual machine cannot be installed at all, which is very annoying and leaves a bad impression on it.

Conditions: 1. Must be running Windows 10 version 2004 and above or Windows 11
2. Turn on virtualization at the location in the picture below. It is usually turned on. It is best to take a look and take precautions.

Start the command window as an administrator and enter: wsl –install

 The download may be very slow, please wait patiently and try not to let it terminate in the middle (keep the network good). If it seems that it has not moved for a long time, you can press Enter a few times to try.


The installation is complete

Remember to restart your computer! ! !

Open the command window as an administrator again and enter the following command

wsl --install -d Ubuntu

It may be a bit slow. If there is no response for a long time, just press Enter.

Enter the username and password (I had an accident when I entered the username and password here)

Username: zhangjingqi

Password: 123456 (It will not be displayed when you enter the password, just know it yourself)

2.2 Docker installation

URL:

https://desktop.docker.com/win/stable/Docker Desktop Installer.exe

After downloading, double-click to run

The picture below means to add a desktop shortcut. You can add it or not, depending on your personal preference, and then click OK.

The following prompts that the installation is successful. Restart the computer and click the blue one.

forced to accept terms

The following interface appears, indicating that the installation is successful.

2.3 Modify the image

{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://cr.console.aliyun.com",
    "https://mirror.ccs.tencentyun.com"
  ],
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "experimental": false,
  "features": {
    "buildkit": true
  }
}

Just keep turning it around and wait for a while, and then it will be fine if you stop turning it.

3. Install portanier (visual Docker operation page)

docker volume create portainer_data

docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/ data portainer/portainer-ee:latest

The picture below shows the installation completed. That’s it.

Enter localhost:9433 in the URL, come out to the page below and click Advanced to continue visiting.

This happens after

—————-
Copyright statement: This article is an original article by CSDN blogger “I Love Brown Bears” and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement when reprinting.
Original link: https://blog.csdn.net/weixin_51351637/article/details/128006765