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

  • 相关阅读:
    Redis 代理 twemproxy
    redis sentinel 集群监控 配置
    RabbitMQ 消息队列 配置
    codis 新版本 CodisLabs 编译安装
    CentOS7 开源跳板机(堡垒机) Jumpserver
    tomcat 优化配置 java-8 tomcat-7
    CentOS 7 安装配置 NFS
    CentOS 7 x64 安装 Ceph
    自动化运维 Ansible
    Java之数据类型讲解
  • 原文地址:https://www.cnblogs.com/djlsunshine/p/10330280.html
Copyright © 2011-2022 走看看