Summary of Docker commonly used commands

Mirror command related

command description Additional parameters example
docker images View all mirrors on the local host -a lists all mirrors
-q only displays the id of the mirror
docker images
docker search image name Search mirror --Filter =STARS=3000 list mirror images with STARS greater than 3000 docker search mysql --filter=STARS=3000
docker pull image name [:tag] Download mirror docker pull mysql:5.7
docker rmi image id Delete mirror -f force deletion, including running docker rmi -f 37323dd2
docker commit container id target image [:tag] Submit mirror -m Descriptive information submitted
-a Author

Container command related

command description Additional parameters example
docker run [optional parameter] image id Start the container --Name="name" Container name
-d Run in background mode
-it Run in interactive mode, enter the container to view content
-p Specify container port mapping Host port: Container port -p 8080:8080
-rm Delete directly after use, general test use
-v Mount the host shared directory, host: container
docker run -it -v /home/ceshi:/home/ceshi centos /bin/bash
docker ps List all running containers -a List all current containers that contain historical running containers
-n=? Display the recently created n containers
-q Only display the container number
docker ps -a
docker rm container id Delete container -f force deletion docker rm -f 1242d2d3f
docker rm -f ${docker ps -aq} Delete all containers docker rm -f ${docker ps -aq}
docker start container id Start the container docker start dwd1d3d2
docker restart container id Restart container docker restart dwd12d12d
docker stop container id Stop the currently running container docker stop wdw1d1d1
docker kill container id Force stop the current container docker kill d1d12dsad1
docker logs -f -t --tail 容器id View log -tf display log
--tail number the number of logs to be displayed
docker logs -tf --tail 100 ddsda1d22
docker top container id View process information ps in the container docker top sdq2d12dsd
docker inspect View image metadata docker inspect wqdwqd12d1
docker exec -it container id /bin/bash Enter the running container -it runs interactively docker exec -it d1dqwd121 /bin/bash
docker attach container Id Attach connection to the specified running mirror under the current Shell docker attach b73232er24
docker cp container id:/container file host path Copy files from the container to the host docker cp dd1d21dad:/home/test.java /home

Build mirror command related

command description Additional parameters example
docker build -t image name. Customize the image through dockerfile [.] represents the dockerfile file in the current directory
docker push image name Push the image to the remote warehouse
docker save image name> xx.tar.gz Save the image to the current directory of the server
docker load -i xx.tar.gz Load the saved image to the server
docker tag container id new image name 修改镜像tag

附加:docker --help参数

在这里插入图片描述
在这里插入图片描述

Guess you like

Origin blog.csdn.net/qdboi/article/details/109261547