zoukankan      html  css  js  c++  java
  • Docker命令

    帮助命令

    docker version

    显示Docker版本信息

    [root@localhost ~]# docker version
    Client: Docker Engine - Community
     Version:           19.03.13
     API version:       1.40
     Go version:        go1.13.15
     Git commit:        4484c46d9d
     Built:             Wed Sep 16 17:03:45 2020
     OS/Arch:           linux/amd64
     Experimental:      false
    
    Server: Docker Engine - Community
     Engine:
      Version:          19.03.13
      API version:      1.40 (minimum version 1.12)
      Go version:       go1.13.15
      Git commit:       4484c46d9d
      Built:            Wed Sep 16 17:02:21 2020
      OS/Arch:          linux/amd64
      Experimental:     false
     containerd:
      Version:          1.3.7
      GitCommit:        8fba4e9a7d01810a393d5d25a3621dc101981175
     runc:
      Version:          1.0.0-rc10
      GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
     docker-init:
      Version:          0.18.0
      GitCommit:        fec3683
    [root@localhost ~]#
    

    docker info

    显示docker的系统信息,包括镜像和容器的数量。

    [root@localhost ~]# docker info
    Client:
     Debug Mode: false
    
    Server:
     Containers: 1
      Running: 0
      Paused: 0
      Stopped: 1
     Images: 1
     Server Version: 19.03.13
     Storage Driver: overlay2
      Backing Filesystem: xfs
      Supports d_type: true
      Native Overlay Diff: true
     Logging Driver: json-file
     Cgroup Driver: cgroupfs
     Plugins:
      Volume: local
      Network: bridge host ipvlan macvlan null overlay
      Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
     Swarm: inactive
     Runtimes: runc
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
     runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
     init version: fec3683
     Security Options:
      seccomp
       Profile: default
     Kernel Version: 3.10.0-1127.19.1.el7.x86_64
     Operating System: CentOS Linux 7 (Core)
     OSType: linux
     Architecture: x86_64
     CPUs: 1
     Total Memory: 1.777GiB
     Name: localhost.localdomain
     ID: 4ARA:NX4Y:7DM7:IGVR:XQNU:PNSQ:SDFN:44U2:VINY:2OMR:VDKO:2SKU
     Docker Root Dir: /var/lib/docker
     Debug Mode: false
     Registry: https://index.docker.io/v1/
     Labels:
     Experimental: false
     Insecure Registries:
      127.0.0.0/8
     Registry Mirrors:
      https://gnxq79wc.mirror.aliyuncs.com/
     Live Restore Enabled: false
    
    [root@localhost ~]#
    

    docker 命令 --help

    帮助命令

    https://docs.docker.com/

    命令:https://docs.docker.com/engine/reference/commandline/

    镜像命令

    docker images

    查看所有本地主机上的镜像

    [root@localhost ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    hello-world         latest              bf756fb1ae65        10 months ago       13.3kB
    
    #解释
    REPOSITORY  镜像仓库源
    TAG			镜像的标签
    IMAGE ID	镜像的ID
    CREATED		镜像的创建时间
    SIZE		镜像的大小
    

    Options选项

    [root@localhost ~]# docker images --help
    
    Usage:	docker images [OPTIONS] [REPOSITORY[:TAG]]
    
    List images
    
    Options:
      -a, --all             Show all images (default hides intermediate images)
          --digests         Show digests  #格式化
      -f, --filter filter   Filter output based on conditions provided  #过滤
          --format string   Pretty-print images using a Go template
          --no-trunc        Don't truncate output
      -q, --quiet           Only show numeric IDs
    
    

    解释

    -a 列出所有镜像

    -q 只显示镜像的ID

    [root@localhost ~]# docker images -a
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    hello-world         latest              bf756fb1ae65        10 months ago       13.3kB
    [root@localhost ~]# docker images -aq
    bf756fb1ae65
    [root@localhost ~]#
    

    搜索命令

    网页搜索

    https://hub.docker.com/

    docker search --help

    [root@localhost ~]# docker search --help
    
    Usage:	docker search [OPTIONS] TERM
    
    Search the Docker Hub for images
    
    Options:
      -f, --filter filter   Filter output based on conditions provided
          --format string   Pretty-print search using a Go template
          --limit int       Max number of search results (default 25)
          --no-trunc        Don't truncate output
    [root@localhost ~]#
    

    例如:

    --filter=STARS=3000 #过滤出镜像收藏大于3000的

    [root@localhost ~]# docker search mysql --filter=STARS=3000
    NAME                DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
    mysql               MySQL is a widely used, open-source relation…   10115               [OK]                
    mariadb             MariaDB is a community-developed fork of MyS…   3715                [OK]                
    [root@localhost ~]#
    

    下载命令

    docker pull

    [root@localhost ~]# docker pull --help
    
    Usage:	docker pull [OPTIONS] NAME[:TAG|@DIGEST]
    
    Pull an image or a repository from a registry
    
    Options:
      -a, --all-tags                Download all tagged images in the repository
          --disable-content-trust   Skip image verification (default true)
          --platform string         Set platform if server is multi-platform capable
      -q, --quiet                   Suppress verbose output
    [root@localhost ~]#
    
    [root@localhost ~]# docker pull mysql
    Using default tag: latest   #如果不写tag:,默认下载最新的版本
    latest: Pulling from library/mysql
    bb79b6b2107f: Pull complete    #分层下载,docker image的核心:联合文件系统
    49e22f6fb9f7: Pull complete 
    842b1255668c: Pull complete 
    9f48d1f43000: Pull complete 
    c693f0615bce: Pull complete 
    8a621b9dbed2: Pull complete 
    0807d32aef13: Pull complete 
    a56aca0feb17: Pull complete 
    de9d45fd0f07: Pull complete 
    1d68a49161cc: Pull complete 
    d16d318b774e: Pull complete 
    49e112c55976: Pull complete 
    Digest: sha256:8c17271df53ee3b843d6e16d46cff13f22c9c04d6982eb15a9a47bd5c9ac7e2d   #签名
    Status: Downloaded newer image for mysql:latest
    docker.io/library/mysql:latest   #真实地址
    [root@localhost ~]
    

    docker pull mysql=docker pull docker.io/library/mysql:latest #等价

    指定下载版本

    docker pull 镜像名:tag

    注:指定下载的版本必须是存在的。

    联合文件系统,公用文件不在下载极大减少占用存储

    比较:

    [root@localhost ~]# docker pull mysql
    Using default tag: latest
    latest: Pulling from library/mysql
    bb79b6b2107f: Pull complete 
    49e22f6fb9f7: Pull complete 
    842b1255668c: Pull complete 
    9f48d1f43000: Pull complete 
    c693f0615bce: Pull complete 
    8a621b9dbed2: Pull complete 
    0807d32aef13: Pull complete 
    a56aca0feb17: Pull complete 
    de9d45fd0f07: Pull complete 
    1d68a49161cc: Pull complete 
    d16d318b774e: Pull complete 
    49e112c55976: Pull complete 
    Digest: sha256:8c17271df53ee3b843d6e16d46cff13f22c9c04d6982eb15a9a47bd5c9ac7e2d
    Status: Downloaded newer image for mysql:latest
    docker.io/library/mysql:latest
    [root@localhost ~]# docker pull mysql:5.7
    5.7: Pulling from library/mysql
    bb79b6b2107f: Already exists 
    49e22f6fb9f7: Already exists 
    842b1255668c: Already exists 
    9f48d1f43000: Already exists 
    c693f0615bce: Already exists 
    8a621b9dbed2: Already exists 
    0807d32aef13: Already exists 
    f15d42f48bd9: Pull complete 
    098ceecc0c8d: Pull complete 
    b6fead9737bc: Pull complete 
    351d223d3d76: Pull complete 
    Digest: sha256:4d2b34e99c14edb99cdd95ddad4d9aa7ea3f2c4405ff0c3509a29dc40bcb10ef
    Status: Downloaded newer image for mysql:5.7
    docker.io/library/mysql:5.7
    [root@localhost ~]#
    

    查看下载的镜像

    删除镜像命令

    docker rmi -f id

    docker rmi -f id1 id2 id3 #删除多个指定的容器镜像

    通过ID删除镜像/通过TAG删除镜像

    再次查看,mysql 5.7已被删除,只删除了部分层。

    删除全部容器镜像

    docker rmi -f $(docker images -aq)

  • 相关阅读:
    基于应用外壳的架构
    示例代码和环境配置
    获取元素位置信息:getBoundingClientRect
    nodejs学习记录
    网页整理 --- 要换工作了,把这一堆网页先存起来
    删除网页上的广告
    周数的处理
    十六进制
    [例]字体改变,文章位置不变
    haslayout和BFC
  • 原文地址:https://www.cnblogs.com/lwenwu/p/14004964.html
Copyright © 2011-2022 走看看