Basic application of docker

Introduction to Docker

Docker is a virtualization platform (official website) https://www.docker.com/ )It was born in early 2013 and implemented based on Google's Go language. You can provide runnable containers for applications through virtualization. In this way, applications can be packaged, tested, and deployed faster.
At this stage, the installation of many application software is implemented to the installation based on docker. For example, mysql, why not install a MySQL directly in the operating system, but use a container instead? Because the process of installing MySQL is not simple. You need to configure the installation source, install dependency packages, and configure MySQL... If you want to install on multiple hosts, each host must perform these cumbersome operations. In case the server hangs, this series of operations will have to be repeated, but with docker, a MySQL container installed and configured can be directly taken to another host for startup, You don't have to reinstall mysql. In addition, docker is also useful to ensure the consistency of development, testing and production environment

Docker core object

Mirror (Image)

Docker image is a special file system( https://hub.docker.com/ ), in addition to providing programs, libraries, resources, configuration files, etc. required by the container runtime, it also includes some configuration parameters prepared for runtime (such as anonymous volumes, environment variables, users, etc.). For example, JDK image, Centos image and MySQL image can be understood as an installer for the time being.

Container

Docker Container can be understood as a carrier running Image. The relationship between Image and Container is like optical disc and optical drive. The Container creates, starts, and then runs the files in the mirror based on the Image.

Architecture analysis of Docker

Docker is an application based on Client/Server architecture, as shown in the figure:

  • Docker Host is our Docker Host (that is, the operating system with docker installed)
  • Registry is a remote repository where docker pulls Images. It provides a large number of Images for downloading. After downloading, it is saved in Images
  • Docker Daemon is a docker service thread that processes docker client commands.
  • Images is the local image repository of Docker. You can view the image files through docker images.

Operation mechanism of Docker

docker pull Execution process:
1)Client sends instructions to docker daemon
2)docker daemon Check the local first images Are there any related mirrors in the
3)If there is no relevant image locally, request the image server to download the remote image locally
docker run Execution process:
1.Check whether the specified image exists locally. If it does not exist, download it from the shared warehouse
2.Create and start a container using a mirror
3.Allocate a file system (short version) linux System), and mount a read-only 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 one from the address pool ip Address to container
6.Execute user specified applications

Installation of Docker

1. Prepare CentOS
2. Open CentOS based on vmware
3. Clone CentOS

Turn on the virtual machine system

Step 1: start the virtual machine. The default account is root/root
Step 2: open the terminal and check the network through ifconfig command

Step 3: connect the virtual machine system through MobaXterm

Uninstall docker

If refueling has been installed, the docker installed online can be uninstalled through the following instructions:

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

Install docker Online

Step 1: install a set of tools

sudo yum install -y yum-utils

Step 2: set the yum warehouse address

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

Step 3: update yum cache

sudo yum makecache fast #yum is the package manager

Step 4: install the new docker

sudo yum install -y docker-ce docker-ce-cli containerd.io

Offline installation of docker

Step 1: Download docker offline package

https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz

Step 2: offline installation tools are required

https://github.com/Jrohy/docker-install/

Step 3: put the downloaded resources in the same directory:
In the linux environment, create the / root/setup/docker directory, and then copy the downloaded resources to this directory (you can directly upload them to the linux directory through MobaXterm tool), for example

[root@centos7964 docker]# pwd
/root/setup/docker
[root@centos7964 docker]# ls -l
 Total consumption 68132
-rw-r--r--. 1 root root 69637582 8 April 13:04 docker-20.10.6.tgz
-rw-r--r--. 1 root root   114793 8 April 13:04 docker.bash
-rwxr-xr-x. 1 root root     7546 8 April 13:04 install.sh

Step 4: perform installation

# Enter the / root/setup/docker folder
cd /root/setup/docker

# Add execution permissions for install.sh
chmod +x install.sh

# install
./install.sh -f docker-20.10.6.tgz

Step 5: check the status after installation

docker info

Tags: CentOS Docker

Posted on Thu, 02 Sep 2021 04:09:02 -0400 by Sorrow