Linux: Docker installation and use


1. Docker installation

1) Check the Linux kernel version
must be 3.10 and above
Command: uname -r

2) Install docker
instruction: yum install docker

Second, the startup and shutdown of Docker

1) Start docker

Instruction: systemctl start docker

2) Start docker automatically at boot

指令:systemctl enable docker

3) Stop docker

Instruction: systemctl stop docker

Three, Docker's common operating instructions

1. Mirror operation

1) Search

Instruction: docker search keyword;
eg: docker search redis

2) Pull

Instruction: docker pull Image name: tag (tag refers to the version number, usually the latest version)
eg: docker pull mysql/docker pull mysql:5.5

3) List

Instructions: docker images

4) Delete

指令:docker rmi image-id
eg: docker rmi 2151acc12881

2, container operation

Software image-run image-generate a container

1) Start the container according to the image

Command: docker run --name custom name -d image name: tag
eg: docker rum --name mytomcat -d tomcat:latest

2) View the running container

Instruction: docker ps

3) Stop the running container

Command: docker stop container ID

4) View all containers

Command: docker ps -a

5) Start an existing container

Instruction: docker start container ID
eg: docker start 0ca572e5017b

6) Delete the existing container

Instruction: docker rm container ID
eg: docker rm 0ca572e5017b

7) Port mapping when creating and starting the container

Instruction: -p System port: container startup port
Instruction: -d (run in the background)
eg: docker run --name Tomcat9.0 -d -p 8888:8080 tomcat

8) View the container log

Instruction: docker logs container ID/container NAME
eg: docker logs 8002743ae896/Tomcat9.0

9) Enter the inside of the container

Command: docker exec -it container ID bash
eg: docker exec -it 38823cd75b62 bash

10) Start all containers

Instruction: docker start $(docker ps -a | awk'{ print $1}' | tail -n +2)
Note that the quotation marks here are English quotation marks (Chinese quotation marks are displayed)

11) Close all containers

Command: docker stop $(docker ps -a | awk'{ print $1}' | tail -n +2)
Note that the quotation marks here are English quotation marks (Chinese quotation marks are displayed)

For more instructions, see the official document:
https://hub.docker.com/search/?type=image

Fourth, how to solve the 2059 problem when connecting to MySql

solution

Guess you like

Origin blog.csdn.net/qq_42697271/article/details/114108307