使用Docker之镜像的拉取、查询、删除

1:查看镜像列表

使用Docker之镜像的拉取、查询、删除

2:拉取镜像

   通过命令可以从镜像仓库中拉取镜像,默认从Docker Hub 获取。

   命令格式:

   docker image pull <repository>:<tag>

  使用Docker之镜像的拉取、查询、删除

  拉取ubuntu仓库,标签为 latest 的镜像,如果省略标签,则docker 会拉取标签为latest的镜像。获取非官方镜像的命令类似,例如:

  docker image pull microsoft/dotnet:latest  

  docker image pull -a  nigelpoulton/tu-demo    //添加 -a 参数可以拉取仓库中所有镜像

3:docker image ls 详解

     docker image ls --filter [dangling|before|since|lable|reference]

     dangling: 值为true或false,true 仅返回悬虚镜像,false仅返回非悬虚镜像。悬虚镜像:指没有标签的镜像。

 使用Docker之镜像的拉取、查询、删除

  before:需要镜像名或镜像ID作为参数,返回之前创建的全部镜像。

 使用Docker之镜像的拉取、查询、删除

since:需要镜像名或镜像ID作为参数,返回之后创建的全部镜像。

使用Docker之镜像的拉取、查询、删除

lable:根据标注的名称或值过滤。略

reference:根据repository和tag搜索,貌似*只能搜一级空间的镜像

使用Docker之镜像的拉取、查询、删除

4:搜索镜像

使用Docker之镜像的拉取、查询、删除

 按照官方或非官方过滤,使用 --filter "is-official=true|false"

 docker search ubuntu --filter "is-official=true"  //只显示官方镜像

 显示是否为自动创建的镜像

 docker search ubuntu --filter "is-automated=true"  //只自动创建的仓库

5:查看镜像分层

    输入命令:docker image inspect ubuntu:latest

    输出:

    [
    {
        "Id": "sha256:3556258649b2ef23a41812be17377d32f568ed9f45150a26466d2ea26d926c32",
        "RepoTags": [
            "ubuntu:latest"
        ],
        "RepoDigests": [
            "ubuntu@sha256:c303f19cfe9ee92badbbbd7567bc1ca47789f79303ddcef56f77687d4744cd7a"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2019-07-23T15:21:13.01464074Z",
        "Container": "3b0e1c94bfe8f2670577cad66142287be14f02c7e49e9d1710073f6b8733bb48",
        "ContainerConfig": {
            "Hostname": "3b0e1c94bfe8",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD [\"/bin/bash\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:6dd4850db8211ac5177f2729ad131f65d6472e95248c92b7fb95acfc609794e7",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "18.06.1-ce",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:6dd4850db8211ac5177f2729ad131f65d6472e95248c92b7fb95acfc609794e7",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 64185514,
        "VirtualSize": 64185514,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/mnt/sda1/var/lib/docker/overlay2/a6003e3ac734728a7ac69eb19453892ad619d1d23f246730c1c59e542f1277c6/diff:/mnt/sda1/var/lib/docker/overlay2/25fc962c359839b2565d1208e2558fa0afd676529ee4b18c87e9346466159feb/diff:/mnt/sda1/var/lib/docker/overlay2/5cc4ecda8dabb8415a0e316a09326a04414e5aefe7a5ee885f6af52838ddce91/diff",
                "MergedDir": "/mnt/sda1/var/lib/docker/overlay2/70dbca5fd3a27da47ff110d91b1b146a905b8e741871db773bfb6a5dc65299e3/merged",
                "UpperDir": "/mnt/sda1/var/lib/docker/overlay2/70dbca5fd3a27da47ff110d91b1b146a905b8e741871db773bfb6a5dc65299e3/diff",
                "WorkDir": "/mnt/sda1/var/lib/docker/overlay2/70dbca5fd3a27da47ff110d91b1b146a905b8e741871db773bfb6a5dc65299e3/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:543791078bdb84740cb5457abbea10d96dac3dea8c07d6dc173f734c20c144fe",
                "sha256:c56e09e1bd18e5e41afb1fd16f5a211f533277bdae6d5d8ae96a248214d66baf",
                "sha256:a31dbd3063d77def5b2562dc8e14ed3f578f1f90a89670ae620fd62ae7cd6ee7",
                "sha256:b079b3fa8d1b4b30a71a6e81763ed3da1327abaf0680ed3ed9f00ad1d5de5e7c"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

在json节点RootFS可以看出ubuntu镜像有四层

使用Docker之镜像的拉取、查询、删除

 

 6:删除镜像

使用Docker之镜像的拉取、查询、删除

 

                

上一篇:keepalive配置(转载)


下一篇:PHP和Java中的SHA256