zoukankan      html  css  js  c++  java
  • Docker容器迁移

    1.将容器保存为镜像(先把容器停止运行不然会有问题)

    docker commit 容器名称 保存的新镜像名称

    操作:
    [root@VM_0_7_centos nexus]# docker commit nexus nexus-z
    sha256:511575baf7897e13c17da89e470b92a522785e2a9e61f32759eb49cc61a4140e
    [root@VM_0_7_centos nexus]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    nexus-z             latest              511575baf789        11 seconds ago      599MB
    

    2.将镜像打为压缩包

    docker save -o 打包后的文件名称 镜像名称

    操作:
    [root@VM_0_7_centos nexus]# docker save nexus-z -o ./nexus-z.tar
    [root@VM_0_7_centos nexus]# ll
    total 596132
    -rw-------  1 root root 610430976 Dec 31 16:33 nexus-z.tar
    

    3.将打包后的镜像压缩包和挂载的文件夹迁移(Mac可以使用Transmit工具)

    4.镜像恢复

    docker load -i 镜像保存的tar包

    操作:

    [root@localhost nexus]# docker load -i ./nexus-z.tar

    5.修改docker-compose.yml文件

    version: '3.7'
    services:
      nexus:
        restart: always
        image: nexus-z #修改这里依赖的镜像
        container_name: nexus
        ports:
          - 8081:8081
        volumes:
          - /usr/local/docker/nexus/data:/nexus-data
    
    

    6.根据docker-compose生成容器

    [root@localhost nexus]# docker-compose up -d
    Creating network "nexus_default" with the default driver
    Creating nexus ... done
    
    通过查看日志发现没有读写文件权限(Permission denied):
    [root@localhost nexus]# docker logs 57ee
    Warning:  Cannot open log file: ../sonatype-work/nexus3/log/jvm.log
    Warning:  Forcing option -XX:LogFile=/tmp/jvm.log
    OpenJDK 64-Bit Server VM warning: Cannot open file ../sonatype-work/nexus3/log/jvm.log due to Permission denied
    java.io.FileNotFoundException: ../sonatype-work/nexus3/tmp/i4j_ZTDnGON8hezynsMX2ZCYAVDtQog=.lock (Permission denied)
    
    修改文件夹操作权限
    [root@localhost nexus]# chmod -R 777 data
    [root@localhost nexus]# ll
    total 596132
    drwxrwxrwx. 16  777 root      4096 Dec 31 16:55 data
    
  • 相关阅读:
    Windows系统下静态库和动态库的生成方法
    c语言 9-9
    c语言中统计字符串中数字字符出现的次数
    c语言 9-8
    c语言 9-7
    c语言中使用putchar显示字符串
    c语言 9-6
    c语言 9-5
    c语言 9-4
    c语言中输出字符串的长度
  • 原文地址:https://www.cnblogs.com/zhufanfan/p/13132054.html
Copyright © 2011-2022 走看看