美文网首页
镜像命令基础

镜像命令基础

作者: 算法设计与分析 | 来源:发表于2021-01-21 11:45 被阅读0次
    1. 查看镜像
    #查看本机所有镜像
    $ docker images
    REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
    mysql         latest    a347a5928046   4 weeks ago     545MB
    nginx         latest    ae2feff98a0c   5 weeks ago     133MB
    hello-world   latest    bf756fb1ae65   12 months ago   13.3kB
    #可选参数
    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 image IDs
    
    
    1. 搜索镜像
    #搜索镜像
    $ docker search mysql
    NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
    mysql                             MySQL is a widely used, open-source relation…   10380     [OK]       
    mariadb                           MariaDB is a community-developed fork of MyS…   3848      [OK]       
    mysql/mysql-server                Optimized MySQL Server Docker images. Create…   761                  [OK]
    percona                           Percona Server is a fork of the MySQL relati…   519       [OK] 
    #可选参数
    #  -f STARS=3000
    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
    
    1. 下载镜像
    #下载镜像
    $ docker pull mysql
    #可选参数
    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
    
    1. 删除镜像
    #删除一个或多个镜像
    $ docker rmi [参数] [镜像ID] [镜像ID] ...
    #当一个镜像有多个名称,应该使用此方式
    $ docekr rmi [参数] [镜像名称]:[版本]
    #可选参数
    Options:
      -f, --force      Force removal of the image
          --no-prune   Do not delete untagged parents
    
    1. 重命名
    #将本地镜像名称和版本重命名,生成一个指向原镜像的新镜像
    $docker tag [老镜像名称]:[老镜像版本] [新镜像名称]:[新镜像版本]
    #演示
    $docker tag nginx:latest nginx1:v1
    

    相关文章

      网友评论

          本文标题:镜像命令基础

          本文链接:https://www.haomeiwen.com/subject/cpvrzktx.html