In normal work ,docker A lot of contact , In addition to the regular use of docker run ,docker stop Wait for the order ,docker There are also a lot of very useful but infrequently used commands , Here's a summary ：
1. docker top
This command is used to view the process information in a container , For example, you want to see a nginx There are several in the container nginx Process time , You can do this ：
docker top 3b307a09d20dUID PID PPID C STIME TTY TIME CMDroot 805 787 0 Jul13 ? 00:00:00 nginx: master process nginx -g daemon off;systemd+ 941 805 0 Jul13 ? 00:03:18 nginx: worker process
2. docker load && docker save
I usually use these two commands to download and package Kubernetes Mirror image , Because you know, the Internet speed in China is not as fast as that in foreign countries . Put together a copy of Java Interview book full version PDF
docker save You can save a mirror image to tar In file , You can do this ：
~ docker save registry:2.7.1 >registry-2.7.1.tar# meanwhile docker load You can take the mirror image from tar File import to docker in ~ docker load < registry-2.7.1.tar
3. docker search
This command can help you search conveniently on the command line DockerHub In the mirror , such as :
~ docker search nginxNAME DESCRIPTION STARS OFFICIAL AUTOMATEDnginx Official build of Nginx. 13519 [OK]jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1846 [OK]richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 780 [OK]linuxserver/nginx An Nginx container, brought to you by LinuxS… 123bitnami/nginx Bitnami nginx Docker Image 87 [OK]tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 85 [OK]jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 73alfg/nginx-rtmp NGINX, nginx-rtmp-module and FFmpeg from sou… 71 [OK]nginxdemos/hello NGINX webserver that serves a simple page co… 57 [OK]jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 53 [OK]nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 37......
Of course, this function may not be particularly easy to use in China , because ......
4. docker events
This command can help you access docker All kinds of event information , Like creating a container or something .
~ docker events2020-07-28T21:28:46.000403018+08:00 image load sha256:432bf69f0427b52cad10897342eaf23521b7d973566354118e9a59c4d31b5fae (name=sha256:432bf69f0427b52cad10897342eaf23521b7d973566354118e9a59c4d31b5fae)
5. docker update
When you docker run After that, I found that there are some parameters that are not the state you want, such as the state you set nginx Containers cpu Or the memory is too small , You can use docker update To modify these parameters .