03 docker basic commands

Check docker version

docker version

View docker information

docker info

view help

docker --help
Service related commands

start up

systemctl start docker

View docker running status

systemctl status docker

stop

systemctl stop docker

reboot

systemctl restart docker

boot

systemctl enable docker

Docker image related commands

List local mirrors

List all local docker iamges

docker images
# You can view the command parameters through the following command
docker images --help

search mirror

#Search mirror
docker search redis
Mirror search address: https://hub.docker.com/

download mirror

#Download the latest (latest) version
docker pull 镜像名
#Download the specified version
docker pull 镜像名:镜像的版本号

delete mirror

Note that if the image has an instance running, it cannot be deleted
#Delete according to the image id, note that if the image id (id prefix) of the two images is the same, it cannot be deleted
docker rmi aa27923130e6

Delete according to image name: version

docker rmi redis:latest

Docker container instance related commands

A container is an instance of an image running. When the image is downloaded and run, it is a container instance.

View docker disk usage

Encountered once: clean up the logs on the disk, it still takes up a lot under the overlay. Stop this container, prune and solve it

docker system df

  • docker system df is similar to the df command on Linux, used to view Docker's disk usage:
  • docker system pruneIt can be used to clean up disks, delete closed containers, useless data volumes and networks, and dangling images (that is, images without tags).
  • docker system prune -aClean up more thoroughly, you can delete all containers that use Docker images. Note that these two commands will delete the temporarily closed container and the temporarily unused Docker image... so be sure to think clearly before using it. I haven't used it, because it will clean up the Docker that is not turned on

Export docker image images

Sometimes the docker container dies, fails to restart, and cannot see the logs. You need to take out this image and run it to see the specific situation.

● docker images export
docker save 98d8bb571885 > /root/rancher.tar
docker save 98d8bb571885 -o /root/rancher.tar

● docker images import
docker load -i /root/rancher.tar
docker file copy

● Copy the files in the container to the server directory
Files in the container: /usr/local/tomcat/webapps/test/js/test.js
Server directory: /opt
Container id or container name: podId
docker cp podId:/usr/local/tomcat/webapps/test/js/test.js /opt

● Copy the server files to the container
docker cp /opt/test.js testtomcat:/srr/local/tomcat/webapps/test/js

Guess you like

Origin blog.csdn.net/qq_41709801/article/details/127339096