Some basic commands, collected on the network

Docker installation: https://www.9ywk.com/344.html

Container management

View Container Name

 docker ps -a

Entering the container terminal

 docker exec -it name bash

Export a file in the container

{alert type="success"}
Example: The container name is d, the file name is file.py, and the path of file.py is in:/python/file.py
Export file.py in container d to/root
{/alert}

Execute under root

 docker cp d:/python/file.py /root

docker

Version Query
docker -v

start-up
systemctl start docker

Start up automatically
systemctl enable docker

stop it
systemctl stop docker

restart
systemctl restart docker

View Status
systemctl status docker

Docker container directory
cd /var/lib/docker/containers

container

View all containers # View all running containers
docker ps -a #docker ps

Stop a container
docker stop containerID

Start a container
docker start containerID

Restart a container
docker restart containerID

Stop all containers
docker stop $(docker ps -a -q)

Delete a container
docker rm containerID
Docker rm - f containerID # Force deletion

Delete all containers
docker rm $(docker ps -a -q)
Docker rm - f $(docker ps - a - q) # Force deletion

image

View Mirror
docker images
delete mirror
docker rmi imageID
Delete all mirrors
docker rmi $(docker images -q)

End