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    

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM