Command#
docker images List all images
docker run -it image Run and keep a specific image
docker ps -a List all containers (including those not running)
docker container prune Remove all stopped containers
docker rm container Remove specified container
docker port container View the ports mapped by the container
docker start container Start the specified container
docker stop container Stop the specified container
docker search image Search for the desired image
Dockerfile#
Trick#
docker run --rm image
Automatically pull the image when it does not exist, run it, and automatically delete the container after the image finishes running
docker run -d -P --name specify a name image
The terminal interface can be closed freely without affecting the continuous running of the container, mapping the container's ports to random ports on the host, and specifying a name for the container
docker run -p host port:image port image
Map the image's port to a port on the host to start the container