• docker镜像文件的导入与导出(docker镜像迁移)


    1、查看镜像ID

    # docker images

    [root@localhost ~]# docker images
    REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
    mytomcat                                               1.0                 f8ec6dad9608        22 minutes ago      612MB
    centos                                                 latest              1e1148e4cc2c        7 weeks ago         202MB

     2、选择要打包的镜像,执行打包命令

    docker save : 将指定镜像保存成 tar 归档文件

    语法:

    docker save [options] image [image……]

    options

    -o :输出到的文件。

    # docker save -o mytomcat.tar mytomcat:1.0

    [root@localhost ~]# docker save -o mytomcat.tar mytomcat:1.0
    [root@localhost ~]# 
    [root@localhost ~]# ls
    anaconda-ks.cfg                  mytomcat.tar  

     3、scp远程复制到迁移的另一台服务器上

    # scp -r mytomcat.tar root@192.168.2.207:/root/

    [root@localhost ~]# scp -r mytomcat.tar root@192.168.2.207:/root/
    The authenticity of host '192.168.2.207 (192.168.2.207)' can't be established.
    ECDSA key fingerprint is fa:8c:a3:e2:79:7e:cc:be:1e:14:35:6a:e7:45:de:95.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '192.168.2.207' (ECDSA) to the list of known hosts.
    root@192.168.2.207's password: 
    mytomcat.tar                                                                                                                             100%  594MB   5.6MB/s   01:46    
    [root@localhost ~]# 

    4、到另一台服务器上导入

    查看已有的镜像

    # docker images

    [root@localhost ~]# docker images
    REPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZE
    mysql                                                  latest              102816b1ee7d        4 weeks ago         486MB

    导入镜像

    # docker load -i mytomcat.tar

    [root@localhost ~]# ls
    mytomcat.tar    software
    [root@localhost ~]# 
    [root@localhost ~]# docker load -i mytomcat.tar
    071d8bd76517: Loading layer [==================================================>]  210.2MB/210.2MB
    cc30c42de5c4: Loading layer [==================================================>]  412.5MB/412.5MB
    Loaded image: mytomcat:1.0
    [root@localhost ~]# 

    查看是否成功导入

    [root@localhost ~]# docker images
    REPOSITORY                                             TAG                 IMAGE ID            CREATED                  SIZE
    mytomcat                                               1.0                 f8ec6dad9608        Less than a second ago   612MB
    mysql                                                  latest              102816b1ee7d        4 weeks ago              486MB

    end

  • 相关阅读:
    世界史上最著名的十大思想实验
    excel 鼠标上下左右移动
    excel 批注
    C# TextWriter类
    C#中的Hashtable
    cython安装、使用
    Java JsonPath grab InvalidPathException in code, you must be catching Java 7's java.nio.file.InvalidPathException instead of JsonPath's com.jayway.jsonpath.InvalidPathExceptio
    Java牛角尖【007】:Java中的Error能不能被Catch
    2016亚洲城市GDP50强出炉
    全国5A级旅游景区已达250家
  • 原文地址:https://www.cnblogs.com/djlsunshine/p/10330280.html
Copyright © 2020-2023  润新知