Docker basic commands and container life cycle and status

Docker basic commands and container life cycle and status

Get help

docker --help Display the help information of the command

docker COMMAND --help Display help information related to subcommand COMMAND

Mirror operation command

docker search [OPTIONS] TERM Search for mirrors from mirror warehouse

docker image pull [OPTIONS] NAME[:TAG|@DIGEST] Pull the image from the mirror repository

docker image ls List existing mirrors

docker image rm [OPTIONS] IMAGE [IMAGE...] Delete the local image file

docker image push [OPTIONS] NAME[:TAG] Push the mirror to the registry

docker image tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG] Tag an image

docker image inspect [OPTIONS] IMAGE [IMAGE...] Mirror details

Container operation command

The container-related commands in the new version are all used docker container开头, and of course it is compatible with the previous command mode.

docker container run -it --name NAME IMAGE runs the container interactively in the foreground

docker container run -d --name NAME IMAGE Run a container in the background

docker container inspect [OPTIONS] CONTAINER [CONTAINER...] Show detailed information about the container

docker container stop CONTAINER Stop a container gracefully

docker container kill CONTAINER Forcibly stop a container

docker container ls -a List all containers, including stopped containers

docker container rm CONTAINER Delete container, only stopped container can be deleted

docker container rm -f CONTAINER Forcibly delete the container, the running container can be deleted

docker container exec -i -t CONTAINER /bin/shRun a command in a running container, run it here /bin/sh, and run it interactively, that is, enter the sh terminal of a container

docker container logs CONTAINER Get the log of a container

Network operation command

docker network lsDisplaying the docker network, of
course, includes creating a network, deleting a network, displaying detailed information of a network, etc. Please use it docker network --helpto view it. The frequency of use is not high.

Container life cycle and status

Picture from the Internet

Docker basic commands and container life cycle and status

Guess you like

Origin blog.51cto.com/zhaochj/2535629