需求說明:docker
在實際使用docker的過程當中,好比某些機器不能上網,恰巧須要某些docker鏡像,通常能夠採用在能上網的機器上,pull下來基礎鏡像,而後將dockerelasticsearch
鏡像保存爲文件,在不能上網的機器上導入。測試
操做過程:spa
1.查看鏡像,而後經過docker save命令將鏡像保存爲文件(歸檔文件)code
[root@localhost ~]# docker save -o es.tar docker.io/elasticsearch:2.3.4 #-o 後面的es.tar是歸檔文件的名字 [root@localhost ~]# ls -l es.tar -rw------- 1 root root 352998912 Dec 7 04:30 es.tar
備註:上面的操做是將一個鏡像保存爲tar文件blog
2.將多個鏡像保存爲tar文件文檔
[root@localhost ~]# docker save -o es.tar docker.io/elasticsearch:2.3.4 es_ik:5.4.3 [root@localhost ~]# ls -l es.tar -rw------- 1 root root 694486528 Dec 7 04:34 es.tar
3.導入保存的鏡像(爲了測試,導入以前先刪除,若是在其餘機器導入則沒有刪除的動做)input
[root@localhost ~]# docker rmi -f docker.io/elasticsearch:2.3.4 Untagged: docker.io/elasticsearch:2.3.4 Untagged: docker.io/elasticsearch@sha256:7a09f0b9204b0e331eb7031bf30e12c8138c53c61938d59bb07b9a1c6de93483 [root@localhost ~]# docker rmi -f es_ik:5.4.3 Untagged: es_ik:5.4.3 Deleted: sha256:d206bf74d16854e62c16f0b790811d8484c4e5c326f6a6d8cbd77cf0a8192464 [root@localhost ~]# docker images | grep es_ik harbor.dcos.xixian.unicom.local/zongbu_newcs_ps/es_ik194 2.3.4 bbdf066111a2 7 days ago 374 MB es_ik1.9.4 2.3.4 82536873c337 8 days ago 359 MB es_ik_1 5.4.3 71c5f7d27500 3 months ago 339 MB [root@localhost ~]# docker images | grep docker.io/elasticsearch docker.io/elasticsearch latest 097d037f8ff8 3 months ago 486 MB
執行導入:io
[root@localhost ~]# docker load --input es.tar Loaded image: es_ik:5.4.3 Loaded image: docker.io/elasticsearch:2.3.4 [root@localhost ~]# docker images | grep docker.io/elasticsearch docker.io/elasticsearch latest 097d037f8ff8 3 months ago 486 MB docker.io/elasticsearch 2.3.4 ca69fe441e9d 2 years ago 345 MB [root@localhost ~]# docker images | grep es_ik harbor.dcos.xixian.unicom.local/zongbu_newcs_ps/es_ik194 2.3.4 bbdf066111a2 7 days ago 374 MB es_ik1.9.4 2.3.4 82536873c337 8 days ago 359 MB es_ik_1 5.4.3 71c5f7d27500 3 months ago 339 MB es_ik 5.4.3 d206bf74d168 3 months ago 334 MB
備註:經過docker load就將tar中的鏡像導入到docker中ast
文檔建立時間:2018年12月7日17:38:30