Commands related to the Docker process
Start the Docker service
systemctl start docker
Copy the code
Stop the Docker service
systemctl stop docker
Copy the code
Restart the Docker service
systemctl restart docker
Copy the code
Check the Docker service status
systemctl status docker
Copy the code
The Docker service starts automatically after startup
systemctl enable docker
Copy the code
Mirror related commands
Search the mirror
#Find the desired image from the networkDocker Search Image nameCopy the code
Pull the mirror
#Download the image from the Docker repository to the local, the image name format is name: version number, if the version number is not specified, the latest version. If you do not know the version of the image, you can go to the Docker Hub to search for the image.Docker pull image nameCopy the code
Look at mirror
#Viewing a Local Mirror
docker images
Copy the code
#View all local mirrors
docker images -a
Copy the code
#View the ID of a local mirror
docker images -q
Copy the code
Remove the mirror
#Remove the mirror-fForcibly deleteDocker rmI [-f]Copy the code
#Deleting all Mirrors
docker rmi -f $(docker images -qa)
Copy the code
Container-specific commands
View running containers
#View the executing container
docker ps
Copy the code
#View all containers
docker ps -a
Copy the code
Create and start the container
Docker run Parameter Description: -i: keeps the container running. By using it with -t. After the it parameters are added, the container is automatically added to the container after it is created and closed after it is exited. -t: reassigns a pseudo-input terminal to the container. It is usually used together with -i. -d: Runs the container in daemon (background) mode. To create a container to run in the background, use Docker Exec to enter the container. -it: The created container is usually called an interactive container. -id: the created container is called a daemon container. --name: the created container is named. -p: mapping port External port: exposed port inside a containerCopy the code
Into the container
Docker exec -it Container ID /bin/bashCopy the code
Viewing Container Information
Docker inspect container ID [container name]Copy the code
Stop the container
Docker stop container idCopy the code
Start the container
Docker start docker startCopy the code
Restart the container
Docker restart Docker restartCopy the code
Force stop container
Docker kill container idCopy the code
Remove the container
#You need to stop the container before deleting itDocker RM Container IDCopy the code
#Forcibly deleting containersDocker rm -f Container idCopy the code
#Forcibly delete all containers
docker rm -f $(docker ps -qa)
Copy the code
Viewing container Logs
Docker logs -f container idCopy the code
Common commands
Build build an IM from a Docker Registry server Port Lookup the public-facing port which is nat-ed to Pause Pause all processes within a container # pause containers ps List containers # List containers pull Pull an image or a repository from the Docker Registry server Repository to the Docker registry server Remove one or more containers # Remove one or more containers # Remove one or more images Run run a command in a new container # Create a new container and run a command save save an image to a tar archive # Search search for an image on the Docker Hub start start a stopped Containers # start containers stop stop a running containers # stop containers tag an image into a repository top Lookup the Running processes of a container unpause unpause a paused container Version Show the docker Wait Block until a container stops, Then print its exit code # age from a Dockerfile # Create a new image from a Cp Copy files/folders from the containers filesystem to the host path Create a new container. Create a new container. Diff Inspect changes on a container's filesystem Exec Run a command in an existing container # export Stream the contents of a container Export the contents of the container as a tar archive [corresponding import] history Show the history of an image # Show a List of historical images formed by the image Import Create a new filesystem image from the contents of a tarball Create a new filesystem image from the contents of a tarball Info Display system-wide information inspect Return low-level information on a container kill kill A running container # kill docker container load load an image from a tar archive Register and Log out of the docker registry serverCopy the code