zoukankan      html  css  js  c++  java
  • Docker导入导出镜像

    从本地文件系统导入镜像

    tar格式镜像包下载地址:http://openvz.org/Download/templates/precreated

    比如,先下载了一个 ubuntu-14.04 的镜像,之后使用以下命令导入:

    # cat ubuntu-14.04-x86_64-minimal.tar.gz |docker import - ubuntu:14.04
    • 1

    然后查看新导入的镜像

    # docker images
    REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
    ubuntu 14.04 05ac7c0b9383 17 seconds ago 215.5 MB
    • 1
    • 2
    • 3

    上传镜像

    用户可以通过 docker push 命令,把自己创建的镜像上传到仓库中来共享。例如,用户在 Docker Hub 上完成注册后,可以推送自己的镜像到仓库中。

    # docker push ouruser/sinatra
    The push refers to a repository [ouruser/sinatra] (len: 1)
    Sending image list
    Pushing repository ouruser/sinatra (3 tags)
    • 1
    • 2
    • 3
    • 4

    存出和载入镜像

    存出镜像

    如果要导出镜像到本地文件,可以使用 docker save 命令

    # sudo docker images
    REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
    ubuntu 14.04 c4ff7513909d 5 weeks ago 225.4 MB
    ...
    # sudo docker save -o ubuntu_14.04.tar ubuntu:14.04
    • 1
    • 2
    • 3
    • 4
    • 5

    载入镜像

    可以使用 docker load 从导出的本地文件中再导入到本地镜像库,例如

    # sudo docker load --input ubuntu_14.04.tar
    或
    # sudo docker load < ubuntu_14.04.tar
    • 1
    • 2
    • 3

    这将导入镜像以及其相关的元数据信息(包括标签等)

    移除本地镜像

    如果要移除本地的镜像,可以使用 docker rmi 命令。注意 docker rm 命令是移除容器

    # sudo docker rmi training/sinatra
    Untagged: training/sinatra:latest
    Deleted: 5bc342fa0b91cabf65246837015197eecfa24b2213ed6a51a8974ae250fedd8d
    Deleted: ed0fffdcdae5eb2c3a55549857a8be7fc8bc4241fb19ad714364cbfd7a56b22f
    Deleted: 5c58979d73ae448df5af1d8142436d81116187a7633082650549c52c3a2418f0
  • 相关阅读:
    WPF 基础
    设计模式
    设计模式
    设计模式
    设计模式
    设计模式
    设计模式
    【DFS】hdu 1584 蜘蛛牌
    【优先队列】hdu 1434 幸福列车
    【最长公共子序列】hdu 1243 反恐训练营
  • 原文地址:https://www.cnblogs.com/405845829qq/p/9598709.html
Copyright © 2011-2022 走看看