• 如何下载docker镜像到本地?
  • 发布于 2个月前
  • 3459 热度
    0 评论

我们在使用docker时经常会将docker仓库的镜像下载到本地,但是很多初学docker的小伙伴可能对于怎么下载docker镜像到本地还不是特别熟悉,本文主要讲述docker下载仓库镜像的常用命令操作,希望对初学者有所帮助。

1.下载docker镜像

从 docker 仓库将镜像下载到本地,命令格式如下:
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
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
  
NAME: 是镜像名,一般的形式 仓库服务器:端口/项目名称/镜像名称
:TAG: 即版本号,如果不指定:TAG,则下载最新版镜像
镜像下载保存的路径: /var/lib/docker/overlay2/镜像ID
注意: 镜像下载完成后,会自动解压缩,比官网显示的可能会大很多
docker pull rockylinux:9-minimal
docker pull ubuntu:focal-20221130
2 查看本地镜像
docker images 可以查看下载至本地的镜像
格式:
docker images [OPTIONS] [REPOSITORY[:TAG]]
docker image ls [OPTIONS] [REPOSITORY[:TAG]]

#常用选项:
-q, --quiet Only show numeric IDs
-a, --all        Show all images (default hides intermediate images)
--digests Show digests
--no-trunc Don't truncate output
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print images using a Go template
执行结果的显示信息说明:
REPOSITORY #镜像所属的仓库名称
TAG #镜像版本号(标识符),默认为latest
IMAGE ID #镜像唯一ID标识,如果ID相同,说明是同一个镜像有多个名称
CREATED #镜像在仓库中被创建时间
SIZE #镜像的大小
Repository仓库
.由某特定的docker镜像的所有迭代版本组成的镜像仓库
.一个Registry中可以存在多个Repository
.Repository可分为“顶层仓库”和“用户仓库”
.Repository用户仓库名称一般格式为“用户名/仓库名”

.每个Repository仓库可以包含多个Tag(标签),每个标签对应一个镜像


总结:

本文主要讲述了如何下载docker镜像到本地及如何使用docker images命令查看下载到本地的镜像,希望对大家理解如何下载docker镜像操作有所帮助。

用户评论