我们在使用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-202211302 查看本地镜像
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仓库
.每个Repository仓库可以包含多个Tag(标签),每个标签对应一个镜像
总结:
本文主要讲述了如何下载docker镜像到本地及如何使用docker images命令查看下载到本地的镜像,希望对大家理解如何下载docker镜像操作有所帮助。