[Docker Series] Docker Command Collection

Environmental information:

docker info: display docker system information, including the number of images and containers
docker version: display docker version information

Container life cycle management:

docker run: command to run the container
docker start: start one or more containers that have been stopped
docker restart: restart the container
docker stop: stop a running container
docker kill: kill a running container
docker rm: delete one or Multiple containers
docker pause: pause all processes in the container
docker unpause: reply to all processes in the container
docker create: create a new container but do not start it
docker exec: execute commands in the running container
Example : docker exec -it container Enter the name or container ID /bin/bash into the container, and then use the shortcut key ctrl+p+q to exit from the container to the host
Insert picture description here

Container operation:

docker ps: list the container
Insert picture description here
docker inspect: get the metadata of the container/image
docker top: view the process information
running in the container , support the ps command docker attach: connect to the running container
docker wait: block the operation until the container stops, then Print out its exit code
docker export: export the file system as a tar archive file STDOUT
docker port: list the port mapping of the specified container
docker logs: get the container log
docker events: get real-time events from the server

Container rootfs command:

docker commit: create a new image from the container
docker cp: used to copy data between the container and the host
docker diff: check the file structure changes in the container

Container mirror warehouse:

docker login: log in to a docker mirror warehouse. If the mirror warehouse address is not specified, it will default to the official warehouse Docker Hub
docker logout: log out of a docker mirror warehouse. If the mirror warehouse address is not specified, the default will be the official warehouse Docker Hub
docker pull: from Pull or update the specified mirror from the mirror warehouse
docker push: upload the local mirror to the mirror warehouse, first log in to the mirror warehouse
docker search: find the mirror from the mirror warehouse

Local mirror management:

docker build: used to create
images using Dockerfile docker images: list local images
Insert picture description here

docker rmi: delete one or more local mirrors
docker tag: mark local mirrors and put them into a warehouse
docker save: save the specified mirrors as a tar archive file
docker import: create mirrors from the summary document
docker load: import and use docker The image exported by the save command
docker history: View the creation history of the specified image

OPTIONS parameter description of docker run

d: Specifies the container running in the foreground or background, the default is false (foreground)
-i: Open STDIN, the console user interaction
-t: distribution tty device, which can support the terminal login, default is false
-u: user-specified container
- a: Log in to the container (must be a container started with docker run -d)
-w: specify the working directory of the
container -c: set the container CPU weight, used in the CPU sharing scenario
-e: specify the environment variable
-m: specify the memory of the container Upper limit
-p: refers to the port exposed by the container
-h: specifies the host name of the container
-v: mounts the storage volume to the container, and mounts to a certain directory on the host machine
-volume-from: mounts the volume on the other container to the container
–Cap-add: add permissions
–cap-drop: delete permissions
–cidfile: after running the container, write the container PID value in the specified file, which is a typical monitoring system usage
–cpuset: set which CPUs the container can use, this Parameters can be used to set some containers to use cpu alone
–device: add host device to the container, equivalent to device pass-through
–dns: specify the dns server of the container
–dns-search: specify the dns search domain name of the container, write it to the container’s etc/ resolv.conf file
–entrypoint: Override the entry point of the image
–env-file: Specify the environment variable file, the file format is one environment variable per line
–expose: Specify the port exposed by the container
–Link: Specify the association between containers, use the IP, env and other information of other containers
–lxc-conf: Specify the configuration file of the container, only use when specifying -exec-driver=lxc
–name: Specify the name of the container
–net= "": The relevant options are as follows
bridge: Docker's default network settings, this mode will allocate a Network Namespace, set IP, etc. for each container, and connect the Docker container on the
host to a virtual bridge; host: the host used by the container network;
containser: NAME_or_ID: other containers using a network, a shared network resources such as IP and PORT;
none: containers its own independent network, but did not make any network settings, such as the distribution veth pair and bridge connections, arranged Wait.
--Privileged=false: Specify whether the container is a privileged container, and the privileged container has all the capabilities.
–restart="": Specify the restart strategy after the container is stopped.
No: Do ​​not restart;
on-failure restart
when the container exits due to failure; always: When the container exits Always restart.
–Rm=false: Specify the container to be automatically deleted after it stops (containers started with docker run -d are not supported)
–sign-proxy=true: Set the proxy to accept and process information, but SIGCHLD, SIGSTOP and SIGKILL cannot be proxied

Guess you like

Origin blog.csdn.net/qq_41979344/article/details/113176716