1. Small talk docker

The following is the owner of personal understanding, if there is any mistake please point out.

1. The docker is what

Docker is a containerized engine. It can be simply understood that docker establishes a virtual machine for us and installs the software we need to install on this virtual machine when we use it.

But Docker is better than virtual machines. (Please find other concepts by yourself)

2.为什么要用docker

Perhaps in the friends have encountered the following situation.

  1. Why does it work on my computer but not on yours?
  2. Xx middleware installation too much trouble ah, and have to create a new user and what configuration.

Docker can solve the above problems. Because Docker creates a new copy of the same virtual container (like a virtual machine) for each computer, there is no environment difference. At the same time, during the installation process, we do not need to input the traditional way of command, all handed to the docker container to execute. This greatly simplifies installation.

3. Basic concepts

Image: can be understood as a software installation package.

Container: a generated VM. (Actually, it’s not.

2. Install the docker

1. Uninstall the Docker container that was previously installed

sudo yum remove docker \ docker-client \ docker-client-latest \docker-common \docker-latest
\docker-latest-logrotate \docker-logrotate \ocker-engine
Copy the code

2. Install the docker

Sudo yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # to install source of a docker Otherwise not find version yum list docker - ce - showduplicates | sort -r sudo yum install docker - ce - 20.10.6 docker - ce - cli - 20.10.6 containerd. IOCopy the code

You can change the version number you want to install according to the following figure

3. Check whether the Docker is installed successfully

yum list installed |grep docker
Copy the code

4. Start docker service (and set startup)

systemctl start docker.service
systemctl enable docker.service
Copy the code

5. Check the Docker service status

Running indicates successful startup.

systemctl status docker
Copy the code

6. Set docker domestic mirror

Edit file on host machine: vim /etc/dock/daemon. json please add to this configuration file (if you don’t have this file, please create one first)

{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
Copy the code

7. Restart the docker

systemctl restart docker.service
Copy the code

3. Common commands

Run docker in Linux master the following command can complete the basic work of docker

Docker images // View images (common) docker RMI image ID // Delete images (common) docker ps -a all containers (common) docker ps view all containers (common) docker RM container ID // Delete container (commonly used) docker start container ID // Start container (commonly used) docker stop container ID // Stop container id // Start container (commonly used) systemctl enable docker // start systemctl Daemon -reload&systemctl restart docker // Docker restart docker logs Container ID // Query container logs (common) docker execit container ID /bin/bash / / command line into the container (common) docker cp/usr/elasticsearch - analysis - ik - 7.13.2. Zip elasticsearch: / usr/share/elasticsearch/plugins // Put the file from the host into container ls // view the container directory exit // exit containerCopy the code