zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    Spark SQL ---一般有用
    idea快捷键
    04.Scala编程实战 ---没看
    03.Scala高级特性 ---没看
    02.Actor编程 ---没看
    01.Scala编程基础 ---没看
    附6、Storm面试题目答疑 ---一般有用
    扩展运算符
    ES6新增数组方法(部分)
    for of 循环
  • 原文地址:https://www.cnblogs.com/djlsunshine/p/10330280.html
Copyright © 2011-2022 走看看