前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker镜像管理

Docker镜像管理

作者头像
星哥玩云
发布2022-09-15 21:20:49
4400
发布2022-09-15 21:20:49
举报
文章被收录于专栏:开源部署

一、docker镜像管理

1.1、镜像搜索-search

代码语言:javascript
复制
从docker镜像仓库模糊搜索镜像
用法:
	docker search 镜像关键字

[root@zutuanxue ~]# docker search centos

NAME          DESCRIPTION           STARS     OFFICIAL        AUTOMATED
centos   The official build of CentOS.   5674   [OK]                


#字段说明:
NAME:镜像名称
DESCRIPTION:镜像描述 
STARS:镜像星级,数字越大表示用的人越多
OFFICIAL:是否为官方  跟[OK]说明是官方
AUTOMATED: 是否为自动化构建的镜像

1.2、镜像下载-pull命令

从docker指定的仓库下载镜像到本地 用法: docker pull 镜像名称

代码语言:javascript
复制
[root@zutuanxue ~]# docker pull centos

Using default tag: latest
latest: Pulling from library/centos
729ec3a6ada3: Pull complete 
Digest: sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

1.3、本地镜像查看-images命令

查看本地存储的镜像

代码语言:javascript
复制
[root@zutuanxue ~]# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
docker.io/gitlab/gitlab-ce   latest              515ad1a75677        7 weeks ago         1.9 GB
docker.io/redis              latest              1319b1eaa0b7        7 weeks ago         104 MB

#字段说明:
REPOSITORY:镜像的名字
TAG:镜像的标签
IMAGE ID:镜像的ID号
CREATED:镜像建立时间
SIZE: 镜像大小

1.4、镜像详细信息-inspect命令

显示镜像的详细导入由save保存出来的压缩文件镜像

用法: docker load -i 镜像压缩文件名称 [镜像名称或者ID]

代码语言:javascript
复制
[root@zutuanxue ~]# docker load -i centos_base.tar 

Loaded image: centos:latest信息

用法:
	docker inspect [镜像名称或者ID]

[root@zutuanxue ~]# docker inspect 0f3e07c0138f 
[
    {
        "Id": "sha256:0f3e07c0138fbe05abcb7a9cc7d63d9bd4c980c3f61fea5efa32e7c4217ef4da",
        "RepoTags": [
            "centos:latest"
        ],
        "RepoDigests": [
            "centos@sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2019-10-01T23:19:57.105928163Z",
        "Container": "711572e3c0c1ac06d5c13c4e668ec170b8ad8786b5f0949f884a5f7fd350d856",
        "ContainerConfig": {
            "Hostname": "711572e3c0c1",
            "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:c0bda62fdbad65a3c6a1843d293a3a47d8233115cc6d384e3cb07c53580a2b43",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20190927",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "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:c0bda62fdbad65a3c6a1843d293a3a47d8233115cc6d384e3cb07c53580a2b43",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20190927",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 219583055,
        "VirtualSize": 219583055,
        "GraphDriver": {
            "Data": {
                "MergedDir": "/var/lib/docker/overlay2/e84fb0b30e3f1cd4a40d2ee6ed522736aedad13fcfce3571075ebbbd665aab4a/merged",
                "UpperDir": "/var/lib/docker/overlay2/e84fb0b30e3f1cd4a40d2ee6ed522736aedad13fcfce3571075ebbbd665aab4a/diff",
                "WorkDir": "/var/lib/docker/overlay2/e84fb0b30e3f1cd4a40d2ee6ed522736aedad13fcfce3571075ebbbd665aab4a/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:9e607bb861a7d58bece26dd2c02874beedd6a097c1b6eca5255d5eb0d2236983"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]

1.5、本地镜像删除-rmi命令

删除本地镜像库中的某个镜像

用法: docker rmi [镜像名称或者ID]

代码语言:javascript
复制
[root@zutuanxue ~]# docker rmi centos

Untagged: centos:latest
Untagged: centos@sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
Deleted: sha256:0f3e07c0138fbe05abcb7a9cc7d63d9bd4c980c3f61fea5efa32e7c4217ef4da
Deleted: sha256:9e607bb861a7d58bece26dd2c02874beedd6a097c1b6eca5255d5eb0d2236983

1.6、镜像保存-save命令

保存镜像为压缩文件

用法: docker save -o 压缩文件名称 [镜像名称或者ID]

代码语言:javascript
复制
[root@zutuanxue ~]# docker save -o centos_base.tar centos

[root@zutuanxue ~]# ls

anaconda-ks.cfg  centos_base.tar

1.7、镜像载入-load命令

导入由save保存出来的压缩文件镜像

用法: docker load -i 镜像压缩文件名称 [镜像名称或者ID]

代码语言:javascript
复制
[root@zutuanxue ~]# docker load -i centos_base.tar 

Loaded image: centos:latest

1.8、镜像管理命令-image命令

镜像管理命令,和上面的命令相似

代码语言:javascript
复制
[root@zutuanxue ~]# docker image --help
Usage:	docker image COMMAND
Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、docker镜像管理
    • 1.1、镜像搜索-search
      • 1.2、镜像下载-pull命令
        • 1.3、本地镜像查看-images命令
          • 1.4、镜像详细信息-inspect命令
            • 1.5、本地镜像删除-rmi命令
              • 1.6、镜像保存-save命令
                • 1.7、镜像载入-load命令
                  • 1.8、镜像管理命令-image命令
                  相关产品与服务
                  容器镜像服务
                  容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
                  领券
                  问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档