docker基于本地模版导入创建镜像

/* 因为直接去网站拿会下载的慢,所以直接到网站里,对着此包--〉右键--〉复制链接地址
    
    网站地址:https://openvz.org/Download/template/precreated
*/

[root@localhost ~]# wget http://download.openvz.org/template/precreated/centos-6-x86-minimal.tar.gz
[root@localhost ~]# cat centos-6-x86-minimal.tar.gz|docker import - centos-6-x86       //import - (+自定义的名字)
b3b4668e82733e0f8d1fefa950266284924f6223673cc72fd6575ddcaa585109
[root@localhost ~]# docker images    //查看刚刚导入的镜像是否存在

/* 
    把现有镜像,导出为一个文件。

    -o + 要导出最后的文件名 + 要导出的文件的标签(名) 或id 
*/        
[root@localhost ~]# docker save -o frankie-centos.tar centos-6-x86
[root@localhost ~]# ls
anaconda-ks.cfg
centos-6-x86_64-minimal.tar.gz
frankie-centos.tar
install.log
install.log.syslog
[root@localhost ~]#

/*用导出的文件恢复本地镜像

1. 先删除镜像

2. 再利用文件恢复

形式:== docker load --input frankie-centos.tar

        == docker load < frankie-centos.tar

"frankie-centos.tar"  --为文件名
*/
    
[root@localhost ~]# docker rmi centos-6-x86
Untagged: centos-6-x86:latest
Deleted: c37f3636c1f8d64c2bfb5fbbfc45ac1ae53aac6ea83c6439410c809cba709a9f
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos_with_net     latest              c5b412fe1c33        About an hour ago   294.1 MB
centos              latest              d83a55af4e75        4 weeks ago         196.7 MB
frankie             latest              d83a55af4e75        4 weeks ago         196.7 MB
[root@localhost ~]# docker load < frankie-centos.tar
[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos-6-x86        latest              c37f3636c1f8        13 minutes ago      343.8 MB
centos_with_net     latest              c5b412fe1c33        About an hour ago   294.1 MB
centos              latest              d83a55af4e75        4 weeks ago         196.7 MB
frankie             latest              d83a55af4e75        4 weeks ago         196.7 MB
[root@localhost ~]#

//可以把自己的镜像传到dockerrhub官网上,前提是注册一个用户
[root@localhost ~]# docker push image_name    
原文地址:https://www.cnblogs.com/frankielf0921/p/5818835.html