Summary of docker Common Commands
- 2021-09-25 00:09:39
- OfStack
docker Installation
1. Requirements: linux kernel 3.10 and above
Kernel version view:
uname -r
Kernel upgrade:
yun update
2. docker installation
yum install docker
3. docker version view
docker -v
4. docker startup
systemctl start docker
5. docker stops
systemctl stop docker
6. Set the startup to start docker
systemctl enable docker
docker Uninstall
View Software Installation
rpm -qa |grep -i docker
Or
yum list installed | grep docker
Uninstall docker
yum remove docker*.x86_64
//Remove associated images and containers
yun update
0
docker Common Operations
1. Search:
docker search Keyword
eg:
docker search mysql
2. Pull
docker pull Mirror Name [: tag] (: tag is optional, refers to the version number, does not specify that tag is latest by default)
docker pull docker pull tomcat:8.0.18-jre7
3. View the local image
yun update
3
4. Delete the image
yun update
4
5. Run the container
yun update
5
Start tomcat:
yun update
6
Start mysql:
docker run --name mysql01 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
Start redis:
docker run -d -p 6379:6379 --name redis01 redis:4.0.12
Start RabbitMQ:
yun update
9
View the redis version under docker:
docker exec -it redis01 redis-server -v
-p: Port mapping, virtual machine port 8888 mapped to tomcat container port 8080
mytomcat: Is a custom name
-d: Indicates background running
6. View the containers running in docker
docker ps
7. View all containers in docker
docker ps -a
8. Stopped containers
docker stop container-id Or Container name
9. Restart the container
docker start container-id
10. Delete the container (the container needs to be stopped)
docker rm container-id
11. View firewall status
service firewalld status
service firewalld stop : Turn off the firewall
12. View the container log
docker logs container-id