docker常用命令详解

docker search 在docker hub中搜索镜像;

[root@docker ~]# docker search nginx
NAME                              DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
nginx                             Official build of Nginx.                        11867               [OK]                
jwilder/nginx-proxy               Automated Nginx reverse proxy for docker con…   1642                                    [OK]
richarvey/nginx-php-fpm           Container running Nginx + PHP-FPM capable of…   737                                     [OK]
linuxserver/nginx                 An Nginx container, brought to you by LinuxS…   73                                      
bitnami/nginx                     Bitnami nginx Docker Image                      70                                      [OK]
tiangolo/nginx-rtmp               Docker image with Nginx using the nginx-rtmp…   51                                      [OK]
nginxdemos/hello                  NGINX webserver that serves a simple page co…   24                                      [OK]
jc21/nginx-proxy-manager          Docker container for managing Nginx proxy ho…   23                                      
nginx/nginx-ingress               NGINX Ingress Controller for Kubernetes         20                                      
jlesage/nginx-proxy-manager       Docker container for Nginx Proxy Manager        20                                      [OK]
schmunk42/nginx-redirect          A very simple container to redirect HTTP tra…   17                                      [OK]
crunchgeek/nginx-pagespeed        Nginx with PageSpeed + GEO IP + VTS + more_s…   13                                      
blacklabelops/nginx               Dockerized Nginx Reverse Proxy Server.          12                                      [OK]
centos/nginx-18-centos7           Platform for running nginx 1.8 or building n…   11                                      
centos/nginx-112-centos7          Platform for running nginx 1.12 or building …   10                                      
nginxinc/nginx-unprivileged       Unprivileged NGINX Dockerfiles                  9                                       
webdevops/nginx                   Nginx container                                 8                                       [OK]
sophos/nginx-vts-exporter         Simple server that scrapes Nginx vts stats a…   5                                       [OK]
1science/nginx                    Nginx Docker images that include Consul Temp…   5                                       [OK]
nginx/nginx-prometheus-exporter   NGINX Prometheus Exporter                       5                                       
mailu/nginx                       Mailu nginx frontend                            3                                       [OK]
pebbletech/nginx-proxy            nginx-proxy sets up a container running ngin…   2                                       [OK]
centos/nginx-110-centos7          Platform for running nginx 1.10 or building …   0                                       
wodby/nginx                       Generic nginx                                   0                                       [OK]
ansibleplaybookbundle/nginx-apb   An APB to deploy NGINX                          0                                       [OK]

docker pull 从docker镜像源服务器拉取指定镜像或者库镜像;

 
docker push 推送指定镜像或者库镜像至docker源服务器;
  1 暂无演示
  2 

docker history 展示一个镜像形成历史;

[root@docker ~]#  docker history  nginx
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
5a3221f0137b        10 days ago         /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B                  
           10 days ago         /bin/sh -c #(nop)  STOPSIGNAL SIGTERM           0B                  
           10 days ago         /bin/sh -c #(nop)  EXPOSE 80                    0B                  
           10 days ago         /bin/sh -c ln -sf /dev/stdout /var/log/nginx…   22B                 
           10 days ago         /bin/sh -c set -x     && addgroup --system -…   56.8MB              
           10 days ago         /bin/sh -c #(nop)  ENV PKG_RELEASE=1~buster     0B                  
           10 days ago         /bin/sh -c #(nop)  ENV NJS_VERSION=0.3.5        0B                  
           10 days ago         /bin/sh -c #(nop)  ENV NGINX_VERSION=1.17.3     0B                  
           11 days ago         /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B                  
           12 days ago         /bin/sh -c #(nop)  CMD ["bash"]                 0B                  
           12 days ago         /bin/sh -c #(nop) ADD file:330bfb91168adb4a9…   69.2MB   

docker images 列出系统当前镜像;

[root@docker ~]# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
                             30ab1584767f        10 hours ago        126MB
zml/centos-ssh       latest              dcb2808921c7        13 hours ago        227MB
nginx                v1                  9b0f60cb8e35        36 hours ago        625MB
tomcat               latest              96c4e536d0eb        4 days ago          506MB
nginx                latest              5a3221f0137b        10 days ago         126MB
redis                latest              f7302e4ab3a8        11 days ago         98.2MB
mysql                latest              62a9f311b99c        11 days ago         445MB
jdeathe/centos-ssh   latest              b276984abde3        2 months ago        225MB

docker run 创建一个新的容器并运行一个命令;

 [root@docker ~]# docker run -itd nginx
 5b6017b66e6cc8b1d0a9c3a5a4290e8560cb89c428025adcd2fa294e09688d5b

docker start 启动容器;

[root@docker ~]# docker commit 5b6017b66e6c >nginx_v1.tar
[root@docker ~]# ls
anaconda-ks.cfg  centos.tar  docker  nginx_v1.tar

docker stop 停止容器;

  1 [root@docker ~]# docker stop 5b6017b66e6c
  2 5b6017b66e6c

docker attach 当前shell下attach连接指定运行镜像;

docker build 通过Dockerfile定制镜像;

 

docker commit 提交当前容器为新的镜像;

[root@docker ~]# docker commit 5b6017b66e6c >nginx_v1.tar
[root@docker ~]# ls
anaconda-ks.cfg  centos.tar  docker  nginx_v1.tar

docker cp 从容器中拷贝指定文件或者目录到宿主机中;

[root@docker ~]# docker cp  centos.tar  7c54241f733f:/root/
[root@docker ~]# docker exec -i 7c54241f733f ls /root/
centos.tar

docker create 创建一个新的容器,同run,但不启动容器;

[root@docker ~]# docker create  -it nginx
7c54241f733f18c0cbae23c88e3855ec8064205a267ef7a6e2e006c4fad63f9f

docker diff 查看docker容器变化;

[root@docker ~]# docker diff 5b6017b66e6c
C /var
C /var/cache
C /var/cache/nginx
A /var/cache/nginx/client_temp
A /var/cache/nginx/fastcgi_temp
A /var/cache/nginx/proxy_temp
A /var/cache/nginx/scgi_temp
A /var/cache/nginx/uwsgi_temp

docker events 从docker服务获取容器实时事件;

 

docker exec 在已存在的容器上运行命令;

docker export 导出容器的内容流作为一个tar归档文件[对应import];

docker import 从tar包中的内容创建一个新的文件系统映像[对应export];

docker info 显示系统相关信息;

docker inspect 查看容器详细信息;

docker kill 指定docker容器;

docker load 从一个tar包中加载一个镜像[对应save];

docker login 注册或者登陆一个docker源服务器;

docker logout Dockerregistry退出;

docker logs 输出当前容器日志信息;

docker port 查看映射端口对应的容器内部源端口;

docker pause 暂停容器;

docker ps 列出容器列表;

docker restart 重启运行的容器;

docker rm 移除一个或者多个容器;

docker rmi 移除一个或多个镜像;

docker save 保存一个镜像为一个tar包[对应load];

docker tag 给源中镜像打标签;

docker top 查看容器中运行的进程信息;

docker unpause 取消暂停容器;

docker version 查看docker版本号;

docker wait 截取容器停止时的退出状态值;

转载于:https://www.cnblogs.com/llinux/p/11410015.html

你可能感兴趣的:(docker常用命令详解)