table of Contents
- 1. Docker installation
- Second, the startup and shutdown of Docker
- Three, Docker's common operating instructions
-
- 1. Mirror operation
- 2, container operation
-
- 1) Start the container according to the image
- 2) View the running container
- 3) Stop the running container
- 4) View all containers
- 5) Start an existing container
- 6) Delete the existing container
- 7) Port mapping when creating and starting the container
- 8) View the container log
- 9) Enter the inside of the container
- 10) Start all containers
- 11) Close all containers
- Fourth, how to solve the 2059 problem when connecting to MySql
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