docker入门与实践之【06-其余镜像制做方式】

1.从压缩包导入

格式:docker import [选项] <文件>|<URL>|- [<仓库名>[:<标签>]]docker

# 从网络导入ubuntu14.04镜像
$ docker import \
    http://download.openvz.org/template/precreated/ubuntu-14.04-x86_64-minimal.tar.gz \
    openvz/ubuntu:14.04

可使用history命令查询构建记录:ubuntu

docker history openvz/ubuntu:14.04
IMAGE               CREATED              CREATED BY          SIZE                COMMENT
f477a6e18e98        About a minute ago                       214.9 MB            Imported from http://download.openvz.org/template/precreated/ubuntu-14.04-x86_64-minimal.tar.gz

2.docker savedocker load

使用 docker save 命令能够将镜像保存为归档文件。网络

好比咱们但愿保存这个 alpine 镜像。code

$ docker image ls alpine
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
alpine              latest              baa5d63471ea        5 weeks ago         4.803 MB

保存镜像的命令为:ip

$ docker save alpine | gzip > alpine-latest.tar.gz

而后咱们将 alpine-latest.tar.gz 文件复制到了到了另外一个机器上,能够用下面这个命令加载镜像:test

$ docker load -i alpine-latest.tar.gz
Loaded image: alpine:latest
相关文章
相关标签/搜索