This is the 11th day of my participation in the Gwen Challenge in November. Check out the details: The last Gwen Challenge in 2021

1. Overview of Docker

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image that can then be distributed to any popular operating system machine, as well as virtualization. Containers are completely sandboxed and have no interface with each other

Docker is an open source project based on the Go language.

Website: www.docker.com

Docs.docker.com

Warehouse address: hub.docker.com

2. Virtualization technology

Virtualization technology features:

1. Too many resources are occupied

2. Many redundant steps

3. Slow start

Containerization technique

Containerization is not about emulating a complete operating system

  • Traditional virtual machines (VMS) virtualize a piece of hardware, run a complete operating system, and install and run software on this system
  • Container applications run directly on the host’s content, container is not its own kernel, there is no virtual our hardware, so it is very portable, each container is isolated from each other, each container has a file system belonging to its own

1. Faster application delivery and deployment

Docker packaged image release test, one-click run,

2. Easier to upgrade and expand containers

With Docker, our deployment applications are like building blocks, with projects packaged as an image and ready to expand

3. Simpler system operation and maintenance

After containerization, our development and testing were highly consistent

4. Efficient use of computing resources

Docker allows kernel-level virtualization, where many container instances can be run on a physical machine and server performance can be squeezed to the limit.

3. Introduction to Docker

Image :(image)

Docker image is like a template that can be used to create container services. Multiple containers can be created through the image, and the project will eventually run in the container.

Container :(container)

Docker uses container technology to run a single application or group of applications independently, created by mirroring,

Start, stop, delete, basic commands

For now, you can think of this container as a simple Linux system

Repository :(repository)

The warehouse is where the image is stored.

Warehouse is divided into: public warehouse and private warehouse.

DockerHub(default foreign)

4. Docker installation

Environment to prepare

1. Linux Basics

2, CentOS7

3. Xshell connects to the server remotely

Environment view

#The kernel is 3.10
[root@VM-0-7-centos /]# uname -r
3.10.0-1127.19.1.el7.x86_64
Copy the code
#System version[root@VM-0-7-centos /]# cat /etc/os-release NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0; 31" CPE_NAME="cpe:/o:centos:centos:7" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-7" CENTOS_MANTISBT_PROJECT_VERSION="7" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="7"Copy the code

The installation

1, unloading

#Uninstall old Versions of Docker
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
Copy the code

2. Required installation package

yum install -y yum-utils
Copy the code

3. Set up the mirror vault

#Setting warehouse Address
yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

#We suggest domestic Ali cloud
#Use ali domestic source to install Docker
yum-config-manager \
   --add-repo \
   http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Copy the code

Note: vignettes

Update your yum package index

yum makecache fast
Copy the code

4, install docker-related engine, Docker-ER is the community version, docker-EE is the enterprise version

yum install docker-ce docker-ce-cli containerd.io
Copy the code

5. After successful installation, start Docker

systemctl start docker
Copy the code

6. Check whether the Docker is installed successfully

Git version Client: Docker engine-community version: 20.10.10 API version: 1.41 Go version: go1.16.9 Git commit: b485636 Built: Mon Oct 25 07:44:50 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.10 API Version: 1.41 (minimum Version 1.12) Go Version: Go1.16.9 Git commit: e2f740d Built: Mon Oct 25 07:43:13 2021 OS/Arch: Linux/AMd64 Experimental: false containerd: Version: 1.4.11 GitCommit: 5 b46e404f6b9f661a205e28d59c982d3634148f8 runc: Version: 1.0.2 GitCommit: V1.0.2-0 -g52b36A2 Docker-init: Version: 0.19.0 GitCommit: de40ad0Copy the code

7. Test whether docker is installed successfully.

docker run hello-world
Copy the code

  • The hello-world mirror was not found
  • Then pull the latest from the repository
  • After downloading, generate a signature, and then actively run docker

8. View the Hello-world mirror

#View the Docker image
docker images
Copy the code

9. One final note: If you don’t want to use Docker, you can download it

#Uninstalling Docker takes only two steps
#1 Uninstalling Dependencies
yum remove docker-ce docker-ce-cli containerd.io

#2. Delete the resourceRm -rf /varlib/docker // Default working path rm -rf /var/lib/containerd // Default container pathCopy the code

5. Docker Run principle

After Docker run starts, Docker looks for the image on the machine.

1. If there is a mirror, run it directly

2, if there is no image, go to DockerHub to download, if there is an image, download to the local, otherwise return an error, can not find the image.