标签:epo minutes min created 格式 tar.gz 提交 方法 文件创建
创建镜像的方法有三种,1、基于已有的镜像的容器创建;2、基于本地模板导入;3、基于dockerfile文件创建。示例:
root@renkailang-K43SV:/home/renkailang# docker run -dit centos /bin/bash
fc72541bad7eb5430c28d06f6da6724bbeaa864f1e08474e97dc8b417f32ff61
root@renkailang-K43SV:/home/renkailang# docker commit fc7254 myrepo:v1
sha256:fad1b5fcac3d9efbde62cc8366e515993c3ced83b6fd7a1bfa4af65d2e3433a4
查看新提交的镜像:
root@renkailang-K43SV:/home/renkailang# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myrepo v1 fad1b5fcac3d About a minute ago 200MB
centos latest 49f7960eb7e4 6 weeks ago 200MB
2、通过本地模板导入镜像
可以使用openvz提供的模板,通过URL在线创建:
root@renkailang-K43SV:/home/renkailang# docker import https://download.openvz.org/template/precreated/debian-7.0-x86-minimal.tar.gz debian:v2
Downloading from https://download.openvz.org/template/precreated/debian-7.0-x86-minimal.tar.gz
sha256:62e8d3459bb271c5e3496b264f34d4baaa322b66870270cade16645425a932cfB/88.44MB
或者 ,通过本地文件导入:
root@renkailang-K43SV:/home/renkailang# ls
debian-7.0-x86-minimal.tar.gz
root@renkailang-K43SV:/home/renkailang# docker import debian-7.0-x86-minimal.tar.gz debian:v3
sha256:33e16d28c5c9828ab9d7745ee082a4eb35fadb50487fd742252a3ed02be91181
3、保存和加载镜像:
查看当前镜像:
root@renkailang-K43SV:/home/renkailang# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos v2 1b6231b7505a 2 minutes ago 288MB
保存当前镜像到tar文件:
root@renkailang-K43SV:/home/renkailang# docker save -o centosv3.tar centos:v2
root@renkailang-K43SV:/home/renkailang# ls
centosv3.tar debian-7.0-x86-minimal.tar.gz
载入tar文件到镜像:
root@renkailang-K43SV:/home/renkailang# docker load -i centosv3.tar
标签:epo minutes min created 格式 tar.gz 提交 方法 文件创建
原文地址:http://blog.51cto.com/13528608/2149212