The docker’s official website

Image: Docker image is like a template, you can create container service from this template, Tomcat image = “run” = “tomcat01 container (server), you can create multiple containers from this image (the final service or project run is in the container).

Container: Docker uses container technology to run a single application or group of applications independently, created by · image.

Start, stop, delete, basic commands can now be understood as recommended Linux system, project

A shared repository a private repository

Install the docker

Environment Preparation:

1. The Linux foundation

2.centos 7

3. Xhell Connects to the remote server

Environment view

Uname -r Displays the system kernel3.10The aboveCopy the code
Cat /etc/os-release Displays the system versionCopy the code

Installation:

Help document: Ctrl+ left mouse button

Linux Installation version

1. Uninstall the earlier version

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. Configure the mirror vault

Yum - config - manager \ - add-repo\https://download.docker.com/linux/centos/docker-ce.repo / / mirror address or abroad Yum - config manager \ - add-repo\https://cr.console.aliyun.com/cn-shanghai/instances/repositories / / domestic ali cloudCopy the code

4. Update yum package index

yum makecache fast
Copy the code

5. Install docker Engine CE Community Edition EE Enterprise Edition

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

6. Start the docker

systemctl start docker
Copy the code

7. If the Docker version information is displayed, the installation is successful

8. Verify that the Docker Engine is properly installed by running the Hello-world image.

docker run hello-world
Copy the code

The image is automatically downloaded if it is not found the first time

Hello from Docker! The installation is successful

9. View the downloaded Hello-Word image

docker images
Copy the code

Learn about uninstalling Docker

Yum remove docker-ce docker-ce-cli containerd. IO delete resources rm -rf /var/lib/docker docker default working path /var/lib/dockerCopy the code

Ali Cloud image acceleration

Objective: To improve efficiency

1. Log in to Aliyun and find the container service

2. Find the mirror accelerator address (bottom of left sidebar)

The operation documentation will tell you how to make centos

3. Find configuration files similar to the following table

1.
sudo mkdir -p /etc/docker
2.
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors":["https://xxxxxx"]
}
EOF
3.
sudo systemctl daemon-reload
4.
sudo systemctl restart docker
Copy the code

Review the Hello-Word process

The underlying principle

How does Docker work

Docker is a client-serve structure of the system, docker daemon running on the host. Access from the client through socker.

Dockerserve executes this command when it receives the Docker-client command

Why is Docker faster than virtual machines

1. Docker has fewer abstraction layers than virtual machines

2. Docker uses the host kernel · Vm uses guest OS

Therefore, when creating a container, Docker does not need to reload an operating system kernel like a virtual machine to avoid boot operations. The guest OS is loaded on the VM at the minute level. Docker, on the other hand, makes use of the host operating system, omitting the complex process at the second level.

Common docker commands

The help command

Docker -version # display version information docker info # display system information including image and container number docker --help # help commandCopy the code

Help document

The mirror command

Docker Images View all host images

Docker Search searches for images

docker search mysql
Copy the code

Docker pull Downloads the image

Docker pull mysql 5.7

Docker RMI delete image

Container order

You need an image to create a container

docker pull centos

Create a new container and start

Lists all running containers

Out of the container

CTRL + P + Q # can exit the container without stoppingCopy the code

Remove the container

Docker rm -f $(docker ps -aq) # delete all containers docker ps -a -qixargs docker rm # delete all containersCopy the code

Start and stop containers

Docker stop docker stop docker stop docker stop docker kill docker stop docker stopCopy the code

Other Common Commands

Background startup container