Docker load 命令参数详解和使用样例

本文记录docker load 命令各个参数的含义和使用样例。

参考

Docker命令参数详解和使用样例文章汇总

https://docs.docker.com/engine/reference/commandline/load/

docker load 参数

  • -i 从tar文件读取数据。 默认从标准输入
  • -q 减少输出内容
[root@vm249 9.8.0.4.1]# docker load --help

Usage:  docker load [OPTIONS]

Load an image from a tar archive or STDIN

Aliases:
  docker image load, docker load

Options:
  -i, --input string   Read from tar archive file, instead of STDIN
  -q, --quiet          Suppress the load output
[root@vm249 9.8.0.4.1]#

默认从标准输入STDIN

[root@vm249 9.8.0.4.1]docker image ls

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

[root@vm249 9.8.0.4.1]docker load < busybox.tar.gz

Loaded image: busybox:latest
[root@vm249 9.8.0.4.1]docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
busybox             latest              769b9341d937        7 weeks ago         2.489 MB

-i --input string

[root@vm249 9.8.0.4.1]# docker load -i gcdw-operator-9.8.0.4.1-202304231127.tar
071d8bd76517: Loading layer [==================================================>]  210.2MB/210.2MB
4bcb77274d4a: Loading layer [==================================================>]  312.8kB/312.8kB
03873a7977c3: Loading layer [==================================================>]  45.05MB/45.05MB
Loaded image: 192.168.8.84/gcdw/gcdw-operator:9.8.0.4.1
[root@vm249 9.8.0.4.1]# 

重复load会在校验后立即完成,不会出现多个

[root@vm249 9.8.0.4.1]# docker load -i gcdw-operator-9.8.0.4.1-202304231127.tar
Loaded image: 192.168.8.84/gcdw/gcdw-operator:9.8.0.4.1
[root@vm249 9.8.0.4.1]#
docker load -i

-q

只输出load结果,没有load进度的过程显示。

[root@vm249 9.8.0.4.1]# docker load -i saas-vsftpd-202304231128.tar -q
Loaded image: 192.168.8.84/gcdw/vsftpd:latest
[root@vm249 9.8.0.4.1]# docker image ls
REPOSITORY                        TAG         IMAGE ID       CREATED        SIZE
goharbor/redis-photon             v2.8.2      6f4498a430ca   3 weeks ago    121MB
goharbor/harbor-registryctl       v2.8.2      fa61a236a6d6   3 weeks ago    142MB
goharbor/registry-photon          v2.8.2      f80e71363231   3 weeks ago    79.3MB
goharbor/nginx-photon             v2.8.2      3d009028f260   3 weeks ago    120MB
goharbor/harbor-log               v2.8.2      2914d282d9bf   3 weeks ago    127MB
goharbor/harbor-jobservice        v2.8.2      40118f1568a8   3 weeks ago    141MB
goharbor/harbor-core              v2.8.2      0bbbd1f379fc   3 weeks ago    165MB
goharbor/harbor-portal            v2.8.2      3e74e0758aa4   3 weeks ago    127MB
goharbor/harbor-db                v2.8.2      5126635ae9f0   3 weeks ago    174MB
goharbor/prepare                  v2.8.2      eb3cf3cdd17a   3 weeks ago    163MB
192.168.8.84/gcdw/gcdw-operator   9.8.0.4.1   ee81cf4b37cc   3 months ago   247MB
192.168.8.84/gcdw/vsftpd          latest      007276d7208b   2 years ago    255MB
[root@vm249 9.8.0.4.1]#