Basic operation of Docker
Operations related to mirroring
# docker search centos # search for images
# docker image ls
# docker images
# docker image rm name/id # Delete an image
View the space occupied by images, containers, and data volumes # docker system df
Docker history nginx # View Image Modification History
Operation of containers
Docker container ls
Docker ps # shows only the containers that are running
Docker container ls-a
Docker ps-a # shows all containers
Docker run-it-- name=mynginx nginx / bin/bash # goes directly to the container. After exit, the container will stop running, but will not disappear.
Docker ps-a | grep mynginx
Docker container rm mynginx # Delete containers that are not running
Docker run-d-name=mynginx nginx # container runs in the background and can be accessed through exec. Whether the container will run for a long time is related to the command specified by docker run and has nothing to do with the-d parameter.
Docker exec-it mynginx / bin/bash # enters the container running in the background. After exit, the container will not exit.
Docker ps | grep mynginx
Docker container rm-f mynginx # forcefully deletes a running container
Docker container start id/name
Docker container restart id/name
Docker container stop id/name
Docker container logs id # View container output
Docker run-- name webserver-d-p 80:80 nginx # the first 80 is the external port, and the second 80 is the container port
Docker diff webserver # View container modifications