Docker?鏡像導入導出過程介紹
docker save
說明:將指定鏡像保存成 tar 歸檔文件,以tar和tar.gz結(jié)尾都行。
語法:
docker save [OPTIONS] IMAGE [IMAGE...]
OPTIONS 說明:
- -o :輸出到的文件。
[root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis v1 cc6cf492f595 6 hours ago 113MB busybox latest beae173ccac6 3 months ago 1.24MB nginx latest 605c77e624dd 3 months ago 141MB redis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp]# docker save -o nginx.tar nginx:latest [root@harbor tmp]# ls nginx.tar [root@harbor tmp]# docker save -o nginx.tar.gz nginx:latest [root@harbor tmp]# ls nginx.tar nginx.tar.gz
docker load
說明:導入使用 ? ?docker save?? 命令導出的鏡像。
語法:
docker load [OPTIONS]
OPTIONS 說明:
- --input , -i :指定導入的文件,代替 STDIN。
- --quiet , -q :精簡輸出信息。
以tar.gz結(jié)尾鏡像包導入
[root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp]# docker load < nginx.tar.gz e379e8aedd4d: Loading layer [==================================================>] 62MB/62MB b8d6e692a25e: Loading layer [==================================================>] 3.072kB/3.072kB f1db227348d0: Loading layer [==================================================>] 4.096kB/4.096kB 32ce5f6a5106: Loading layer [==================================================>] 3.584kB/3.584kB d874fd2bc83b: Loading layer [==================================================>] 7.168kB/7.168kB Loaded image: nginx:latest [root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 605c77e624dd 3 months ago 141MB redis latest 7614ae9453d1 3 months ago 113MB
以tar結(jié)尾鏡像包導入
[root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp]# docker load < nginx.tar e379e8aedd4d: Loading layer [==================================================>] 62MB/62MB b8d6e692a25e: Loading layer [==================================================>] 3.072kB/3.072kB f1db227348d0: Loading layer [==================================================>] 4.096kB/4.096kB 32ce5f6a5106: Loading layer [==================================================>] 3.584kB/3.584kB d874fd2bc83b: Loading layer [==================================================>] 7.168kB/7.168kB Loaded image: nginx:latest [root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 605c77e624dd 3 months ago 141MB redis latest 7614ae9453d1 3 months ago 113MB
Docker export 命令
說明:將指定運行或停止的容器導出為tar包。
語法:
docker export [OPTIONS] CONTAINER
OPTIONS說明:
- -o :將輸入內(nèi)容寫到文件。
使用redis:latest
鏡像運行一個docker redis容器。
[root@harbor tmp]# docker run -d --name redis redis:latest 00bd9bf582ffdf7dc89793252de9b663ce5b685061bb3652d167924270bed423 [root@harbor tmp]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 00bd9bf582ff redis:latest "docker-entrypoint.s…" 3 seconds ago Up 2 seconds 6379/tcp redis
將運行中的redis容器導出稱為redis.tar.gz包。
[root@harbor tmp]# docker export -o redis.tar.gz redis [root@harbor tmp]# ls nginx.tar nginx.tar.gz redis.tar.gz
停止redis容器
[root@harbor tmp]# docker stop redis redis
將已經(jīng)停止的redis容器導出為redis1.tzr.gz包
[root@harbor tmp]# docker export -o redis1.tar.gz redis [root@harbor tmp]# ls nginx.tar nginx.tar.gz redis1.tar.gz redis.tar.gz
Docker import
說明:從 tar包導入內(nèi)容以docker 鏡像。
語法
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
OPTIONS說明:
- -c :應用docker 指令創(chuàng)建鏡像;
- -m :提交時的說明文字
您可以指定一個??URL?
?或??-?
?(破折號)直接從??STDIN?
?. ??URL?
?可以指向包含文件系統(tǒng)的存檔(.tar、.tar.gz、.tgz、.bzip、.tar.xz 或 .txz)或 Docker 主機上的單個文件。 如果你指定一個存檔,Docker 會在相對于??/?
? (root) 的容器中解壓它。如果指定單個文件,則必須指定主機內(nèi)的完整路徑。要從遠程位置導入,請指定以or協(xié)議??URI?
?開頭的 a。??http://?
???https://?
?
[root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp]# docker import redis1.tar.gz redis:v1 sha256:07d6e5a00daa386ed5117d7bf7751f74b46f5831aea69036580cd509bb6781e7 [root@harbor tmp]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE redis v1 07d6e5a00daa 2 seconds ago 109MB redis latest 7614ae9453d1 3 months ago 113MB
通過url導出鏡像
docker import https://example.com/exampleimage.tgz
到此這篇關(guān)于Docker 鏡像導入導出過程介紹的文章就介紹到這了,更多相關(guān)Docker 鏡像導入導出內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Docker?Compose構(gòu)建Jenkins的實現(xiàn)
本文主要介紹了Docker?Compose構(gòu)建Jenkins的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-06-06超詳細Docker Desktop下安裝rocketmq的教程
這篇文章主要介紹了Docker Desktop下安裝rocketmq,本文內(nèi)容通過圖文操作命令給大家講解的非常詳細,需要的朋友可以參考下2021-10-10dockerfile-maven-plugin使用指南小結(jié)
最近在將應用部署到容器平臺,需要在打包時生成docker鏡像,在網(wǎng)上首先搜到了docker-maven-plugin這個插件,本文就來介紹了dockerfile-maven-plugin使用小結(jié),感興趣的可以了解一下2021-09-09在IntelliJ IDEA中使用Docker的開發(fā)指南
這篇文章主要給大家介紹了在IntelliJ IDEA中使用Docker開發(fā)指南,文中通過圖文介紹的非常詳細,對我們的使用Docker有一定的幫助,需要的朋友可以參考下2023-09-09Docker提示permission?denied錯誤的解決方案
這篇文章主要給大家介紹了關(guān)于Docker提示permission?denied錯誤的解決方案,出現(xiàn)這個問題是因為宿主機的當前運行用戶和docker容器里面的運行用戶不一致導致訪問權(quán)限問題,需要的朋友可以參考下2023-08-08docker中的jenkins之流水線構(gòu)建項目步驟詳解
jenkins有2種流水線分為聲明式流水線與腳本化流水線,腳本化流水線是jenkins舊版本使用的流水線腳本,新版本Jenkins推薦使用聲明式流水線,本文給大家介紹docker中的jenkins之流水線構(gòu)建項目,感興趣的朋友一起看看吧2023-08-08