易学笔记-第3章 镜像/3.6 导出和导入镜像

  • 导出和导入镜像
  1. 导出镜像:导出镜像到本地文件 docker save命令

    [root@zabbix ~]# docker save -o  ubuntu_latest.tar.gz  docker.io/ubuntu

    ubuntu_latest.tar.gz:导出文件名

    docker.io/Ubuntu:镜像名

    [root@zabbix ~]# ll -h

    total 120M

    -rw-------. 1 root root 1.3K Aug 31 15:27 anaconda-ks.cfg

    drwxr-xr-x. 4 root root   39 Sep 18 15:06 lxh

    -rw-------. 1 root root 120M Sep 20 15:02 ubuntu_latest.tar.gz

    ubuntu_latest.tar.gz:这里的120M 与镜像中的Size一样

  2. 导入镜像:从本地文件docker load 为镜像

    [root@zabbix ~]# docker images

    REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE

    docker.io/wordpress        latest              2c69ebee76a8        5 days ago          408.3 MB

     [root@zabbix ~]# docker load < ubuntu_latest.tar.gz   导入镜像包

    a2022691bf95: Loading layer [==================================================>] 125.6 MB/125.6 MB

    ae620432889d: Loading layer [==================================================>] 15.87 kB/15.87 kB

    c56153825175: Loading layer [==================================================>] 14.85 kB/14.85 kB

    f96e6b25195f: Loading layer [==================================================>] 5.632 kB/5.632 kB

    7f7a065d245a: Loading layer [==================================================>] 3.072 kB/3.072 kB

    Loaded image: docker.io/ubuntu:latest>                                          ]    512 B/3.072 kB

    [root@zabbix ~]# docker images

    REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE

    docker.io/ubuntu           latest              2d696327ab2e        31 hours ago        121.6 MB

    docker.io/wordpress        latest              2c69ebee76a8        5 days ago          408.3 MB

猜你喜欢

转载自blog.csdn.net/u011830122/article/details/84096429
今日推荐