Docker?鏡像導(dǎo)入導(dǎo)出過(guò)程介紹
docker save
說(shuō)明:將指定鏡像保存成 tar 歸檔文件,以tar和tar.gz結(jié)尾都行。
語(yǔ)法:
docker save [OPTIONS] IMAGE [IMAGE...]
OPTIONS 說(shuō)明:
- -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
說(shuō)明:導(dǎo)入使用 ? ?docker save?? 命令導(dǎo)出的鏡像。
語(yǔ)法:
docker load [OPTIONS]
OPTIONS 說(shuō)明:
- --input , -i :指定導(dǎo)入的文件,代替 STDIN。
- --quiet , -q :精簡(jiǎn)輸出信息。
以tar.gz結(jié)尾鏡像包導(dǎo)入
[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é)尾鏡像包導(dǎo)入
[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 命令
說(shuō)明:將指定運(yùn)行或停止的容器導(dǎo)出為tar包。
語(yǔ)法:
docker export [OPTIONS] CONTAINER
OPTIONS說(shuō)明:
- -o :將輸入內(nèi)容寫到文件。
使用redis:latest鏡像運(yùn)行一個(gè)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
將運(yùn)行中的redis容器導(dǎo)出稱為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容器導(dǎo)出為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
說(shuō)明:從 tar包導(dǎo)入內(nèi)容以docker 鏡像。
語(yǔ)法
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
OPTIONS說(shuō)明:
- -c :應(yīng)用docker 指令創(chuàng)建鏡像;
- -m :提交時(shí)的說(shuō)明文字
您可以指定一個(gè)??URL??或??-??(破折號(hào))直接從??STDIN??. ??URL??可以指向包含文件系統(tǒng)的存檔(.tar、.tar.gz、.tgz、.bzip、.tar.xz 或 .txz)或 Docker 主機(jī)上的單個(gè)文件。 如果你指定一個(gè)存檔,Docker 會(huì)在相對(duì)于??/?? (root) 的容器中解壓它。如果指定單個(gè)文件,則必須指定主機(jī)內(nèi)的完整路徑。要從遠(yuǎn)程位置導(dǎo)入,請(qǐng)指定以or協(xié)議??URI??開(kāi)頭的 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
通過(guò)url導(dǎo)出鏡像
docker import https://example.com/exampleimage.tgz
到此這篇關(guān)于Docker 鏡像導(dǎo)入導(dǎo)出過(guò)程介紹的文章就介紹到這了,更多相關(guān)Docker 鏡像導(dǎo)入導(dǎo)出內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Docker鏡像的導(dǎo)入導(dǎo)出的實(shí)現(xiàn)方法
- docker鏡像的導(dǎo)入和導(dǎo)出的實(shí)現(xiàn)
- Docker鏡像的導(dǎo)入導(dǎo)出代碼實(shí)例
- Docker鏡像與容器的導(dǎo)入導(dǎo)出操作實(shí)踐
- Docker鏡像與容器的導(dǎo)入導(dǎo)出以及常用命令總結(jié)
- docker鏡像導(dǎo)入導(dǎo)出的兩種方法
- docker images導(dǎo)入導(dǎo)出方式
- idea使用docker生成鏡像(打包鏡像,導(dǎo)入鏡像,導(dǎo)出鏡像)
- Docker中conda環(huán)境的導(dǎo)出和導(dǎo)入
相關(guān)文章
使用Docker安裝部署MySQL和Redis的詳細(xì)過(guò)程
這篇文章主要介紹了使用Docker安裝部署MySQL和Redis,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-06-06
Docker安裝MySql8并遠(yuǎn)程訪問(wèn)的實(shí)現(xiàn)
本文主要介紹了Docker安裝MySql8并遠(yuǎn)程訪問(wèn)的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07
docker安裝Jenkins配置Gitee SSH密鑰踩坑解決
這篇文章主要為大家介紹了docker安裝Jenkins配置Gitee SSH密鑰踩坑解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-08-08
docker如何對(duì)已經(jīng)啟動(dòng)的容器添加目錄映射(掛載目錄)
當(dāng)我們創(chuàng)建容器之后,不可避免會(huì)遇到修改配置文件的操作,下面這篇文章主要給大家介紹了關(guān)于docker如何對(duì)已經(jīng)啟動(dòng)的容器添加目錄映射(掛載目錄)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-02-02
docker安裝RocketMQ的實(shí)現(xiàn)步驟
本文主要介紹了docker安裝RocketMQ的實(shí)現(xiàn)步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11

