Docker common commands

Time:2021-9-23

1. View all containers

docker ps -a

2. Enter a container

docker exec -it nginx bash

3. Stop a container

docker stop name

4. Start a container

 docker restart name

5. Docker run – run (create) a container

docker run -d -p 0.0.0.0:18080:8080 --name nginx1 nginx
-d: Let the container run in the background
-P: Map the network port used inside the container to the host we use
-p: Specify port
--Name: set container naming
Nginx is the container image. Docker pull nginx pulls the image;

6. Delete a container

docker rm container_name

7. Delete an image

docker rmi image_name

Docker common commands

Docker common commands

Docker common commands

Docker common commands

Docker common commands

Docker common commands

This work adoptsCC agreement, reprint must indicate the author and the link to this article