Previous: Docker (2)-Installation
1. Help command
command | description |
---|---|
docker version | View docker version |
docker info | View docker description information (more detailed than docker version) |
docker help | View common docker instructions |
2. Mirror commands
Note: [OPTIONS] in the table is optional!
command | description | OPTIONS description |
---|---|---|
docker images [OPTIONS] | View the image on the local host | -a: list all local mirrors (including the intermediate image layer) -q: only display mirror IDs -digests: only display mirror summary information |
docker search [OPTIONS] Image file name | Find an image file | --No-trunc: display the complete image file description -s: list images with a collection number of not less than the specified value -automated: list only images of automated build type |
Docker pull an image file name | Download image file | |
Docker rmi image file ID | Delete mirror | -f image ID (delete single) -f image name 1: TAG image name 2: TAG (delete multiple) docker rmi -f $ (docker: images -qa) (delete all) |
docker images
Command introduction:
command | description |
---|---|
REPOSITORY | Represents mirrored warehouse source |
TAG | Mirror label |
IMAGE ID | Mirror ID (similar to the primary key ID in mysql) |
CREATED | Image creation time |
SIZE | Image size |
The same warehouse source can have multiple TAG
, multiple TAG
mirrors representing multiple versions. It looks like Linux
the linux
installation packages on our official website have different version numbers. We can REPOSITORY:TAG
define a different image.
latest
Indicates the latest version
3. Container commands
command | description | OPTIONS description |
---|---|---|
docker run [OPTIONS] Image name [COMMAND] [ARG…] | Create and start a container | –Name = “New container name”: Specify a new name for the container -d: Run the container in the background, and return the container ID, that is, start the daemon container -i: Run the container in interactive mode, usually use -t with -t Re-enter a pseudo input terminal for the container, usually used together with -i -P: random port mapping -p: specified port mapping, there are these four formats: (ip: hostPort: containerPort) (ip :: containerPort) (hostPort: containerPort) containerPort |
docker ps[OPTIONS] | List all currently running containers | -a: list currently running containers + historically run -l: display recently created containers -n: display the last n created containers docker ps -n 3 -q: silent mode, only display the container number -no-trunc: no Truncate the output |
exit | The container stops exiting | |
ctrl+P+Q | Container does not stop exiting | |
docker start container ID / container name | Start the container | |
docker restart container ID / container name | Restart the container | |
docker stop container ID / container name | Stop the container | |
docker rm -f ${docker pa -a -q} | Delete multiple containers at once | |
docker ps -a -q |xargs docker rm |
Delete multiple containers at once | |
docker run -d container name | Start the daemon container | |
docker logs -f -t --tail 容器ID | View container logs | -t: add timestamp -f: print with the latest log –tail number: show how many last |
docker top container ID | View the processes running in the container | |
docker exec -it 容器ID bashShell | Enter the running container and interact with the command line (open a new terminal in the container and can start a new process) | docker exec -it asg856asf5s56g /usr/local/ |
docker attach container ID | Enter the running container and interact with the command line (direct access to the terminal where the container starts the command will not start a new process) |