• Docker 镜像的导入和导出


    镜像的导入和导出

    export 和improt

    
    [root@#localhost docker]# docker run -ti  ubuntu:update /bin/bash
    root@cbe3cb7799ed:/# ls
    bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  update.txt  usr  var
    
    [root@#localhost docker]# 
    [root@#localhost docker]# docker ps -a
    CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                        PORTS                                   NAMES
    cbe3cb7799ed        ubuntu:update                  "/bin/bash"              47 seconds ago      Exited (1) 6 seconds ago                                              adoring_kare
    812a997f614a        ubuntu:14.04                   "/bin/bash"              16 minutes ago      Exited (0) 8 minutes ago                                              zealous_euler
    69304dea46c7        gitlab/gitlab-ce:latest        "/assets/wrapper"        2 hours ago         Exited (127) 53 minutes ago                                           competent_minsky
    67ba866e21b0        gitlab/gitlab-ce:latest        "/assets/wrapper"        2 hours ago         Exited (137) 2 hours ago                                              hungry_hoover
    2a3d08a0a2ff        twang2218/gitlab-ce-zh:9.0.3   "/assets/wrapper"        2 hours ago         Exited (137) 2 hours ago                                              nervous_wozniak
    6db49540be99        twang2218/gitlab-ce-zh:9.0.3   "/assets/wrapper"        2 hours ago         Exited (255) 2 hours ago      22/tcp, 443/tcp, 0.0.0.0:3000->80/tcp   romantic_elion
    b08a6d6ed716        gitlab/gitlab-ce:latest        "/assets/wrapper"        2 hours ago         Exited (255) 2 hours ago      22/tcp, 443/tcp, 0.0.0.0:8080->80/tcp   competent_brahmagupta
    33fd0b1ebd27        gitlab/gitlab-ce:latest        "/assets/wrapper"        3 hours ago         Exited (127) 2 hours ago                                              loving_brattain
    6f53620a930c        twang2218/gitlab-ce-zh:9.0.3   "/assets/wrapper"        3 hours ago         Exited (127) 2 hours ago                                              brave_galileo
    88df78f77c4e        ubuntu:14.04                   "sleep 360"              4 days ago          Exited (137) 4 days ago                                               testcopy
    81a879a36bd3        wordpress                      "docker-entrypoint..."   4 days ago          Exited (0) 4 days ago                                                 wordpress
    a57a3cc492b7        mysql                          "docker-entrypoint..."   4 days ago          Exited (0) 4 days ago                                                 mysqlwp
    
    # 将镜像做成的容器导出到文件
    [root@#localhost docker]# docker export cbe3cb7799ed > update.tar
    
    
    # 创建一个新静像从基于导出的容器文件
    [root@#localhost /]# docker import - update < update.tar 
    sha256:fd00d520a43eb5dc6cca8717fe0ca04cfdc53b02cad2fb5b50d877b8e6d6c3bc
    [root@#localhost /]# docker images
    REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
    update                      latest              fd00d520a43e        13 seconds ago      165 MB
    ubuntu                      update              317f10258460        11 minutes ago      188 MB
    twang2218/gitlab-ce-zh      9.0.3               36172b5fefab        44 hours ago        1.19 GB
    gitlab/gitlab-ce            latest              5eff2e44957c        2 days ago          1.11 GB
    mysql                       latest              9546ca122d3a        8 days ago          407 MB
    wordpress                   latest              4ad41adc2794        2 weeks ago         401 MB
    ubuntu                      14.04               7c09e61e9035        5 weeks ago         188 MB
    daocloud.io/library/nginx   1.7.1               e3e043d3ed2f        2 years ago         499 MB
    

    save 和load

    (像当与镜像的备份和恢复)

    # update是一个已经存在的镜像
    [root@#localhost /]# docker save -o update1.tar update
    [root@#localhost /]# ls
    bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  update1.tar  update.tar  usr  var
    [root@#localhost /]# du -sh update1.tar 
    166M    update1.tar
    
    # 删除update镜像
    [root@#localhost /]# docker rmi update
    Untagged: update:latest
    Deleted: sha256:fd00d520a43eb5dc6cca8717fe0ca04cfdc53b02cad2fb5b50d877b8e6d6c3bc
    Deleted: sha256:14cc8cd7b783152682835346e5fe90860a9feeb684866688692285319d4e97ad
    
    [root@#localhost /]# docker images
    REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
    ubuntu                      update              317f10258460        16 minutes ago      188 MB
    twang2218/gitlab-ce-zh      9.0.3               36172b5fefab        44 hours ago        1.19 GB
    gitlab/gitlab-ce            latest              5eff2e44957c        2 days ago          1.11 GB
    mysql                       latest              9546ca122d3a        8 days ago          407 MB
    wordpress                   latest              4ad41adc2794        2 weeks ago         401 MB
    ubuntu                      14.04               7c09e61e9035        5 weeks ago         188 MB
    daocloud.io/library/nginx   1.7.1               e3e043d3ed2f        2 years ago         499 MB
    
    #导入镜像
    [root@#localhost /]# docker load < update1.tar 
    14cc8cd7b783: Loading layer [==================================================>] 173.8 MB/173.8 MB
    Loaded image: update:latest
    [root@#localhost /]# docker images
    REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
    update                      latest              fd00d520a43e        6 minutes ago       165 MB
    ubuntu                      update              317f10258460        17 minutes ago      188 MB
    twang2218/gitlab-ce-zh      9.0.3               36172b5fefab        44 hours ago        1.19 GB
    gitlab/gitlab-ce            latest              5eff2e44957c        2 days ago          1.11 GB
    mysql                       latest              9546ca122d3a        8 days ago          407 MB
    wordpress                   latest              4ad41adc2794        2 weeks ago         401 MB
    ubuntu                      14.04               7c09e61e9035        5 weeks ago         188 MB
    daocloud.io/library/nginx   1.7.1               e3e043d3ed2f        2 years ago         499 MB
    [root@#localhost /]# 
  • 相关阅读:
    开源数学库
    ZendFramework综述
    MySQL临时表
    GMP for PHP
    ubuntu的LAMP环境搭建
    linux与windows区别
    js对象与打印对象
    MySQL 多库操作
    ubuntu文件系统综述
    波形声音整理资料(for Project1)
  • 原文地址:https://www.cnblogs.com/Presley-lpc/p/9390136.html
Copyright © 2020-2023  润新知