编程知识 cdmana.com

Docker container operation

Docker in , After an image file runs , A corresponding container will be generated .

One 、 Running the mirror , Create a container

#  Abbreviation  
docker run  Mirror image ID| Image name [:tag] 
#  complete 
docker run -d -p  Host port : Container port  --name  Container name   Mirror image ID| Image name [:tag] 
# -d: Background start 
# -p  Host port : Container port : Map the current system port and container port 
# --name  Container name : Specify the name of the container 

eg: function tomcat

docker run -d -p 8080:8080 --name  tomcat9 8b

In the local Windows visit :

Two 、 Look at the container

docker ps [-aq] | docker container ls [-aq]
# -a: View all ( Including those that are not running )
# -q: Check the identification of the container 

3、 ... and 、 View container log

docker logs -f  Containers ID
# -f: Scroll through the last few lines  

Four 、 Into the container

docker exec -it  Containers ID bash|/bin/bash

The exit command from inside the container is :exit

5、 ... and 、 Stop container

docker stop  Containers ID	# Stop specifying containers 
docker stop $(docker ps -aq)	# Stop all containers 

6、 ... and 、 Start the container

docker start  Containers ID	# Start the specified container 
docker start $(docker ps -aq)	# Start all containers 

7、 ... and 、 Delete container

You must stop the container before deleting it

docker rm  Containers ID	# Deletes the specified container 
docker rm $(docker ps -aq)	# Delete all containers 

版权声明
本文为[wind-ranger]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/04/20210421233112204E.html

Scroll to Top