Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of Docker Image Import and Export

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "the method of import and export of Docker image". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the method of importing and exporting Docker images".

Docker save

Description: save the specified image as a tar archive file, ending with either tar or tar.gz.

Syntax:

Docker save [OPTIONS] IMAGE [IMAGE...]

OPTIONS description:

-o: the file to which you output.

[root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEredis v1 cc6cf492f595 6 hours ago 113MBbusybox latest beae173ccac6 3 months ago 1.24MBnginx latest 605c77e624dd 3 months ago 141MBredis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp] # docker save-o nginx.tar nginx:latest [root@harbor tmp] # lsnginx.tar [root@harbor tmp] # docker save-o nginx.tar.gz nginx:latest [root@harbor tmp] # lsnginx.tar nginx.tar.gzdocker load

Description: import images exported using the docker save command.

Syntax:

Docker load [OPTIONS]

OPTIONS description:

-- input,-I: specify the imported file instead of STDIN.

-- quiet,-Q: simplify the output information.

Import the image package ending with tar.gz into [root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEredis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp] # docker load

< nginx.tar.gze379e8aedd4d: Loading layer [==================================================>

] 62MB/62MBb8d6e692a25e: Loading layer [= = >] 3.072kB/3.072kBf1db227348d0: Loading layer [= = >] 4.096kB/4.096kB32ce5f6a5106: Loading layer [= = >] 3.584kB/3.584kBd874fd2bc83b: Loading layer [= = >] 7.168kB/7.168kBLoaded image: nginx:latest [root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx latest 605c77e624dd 3 months ago 141MBredis latest 7614ae9453d1 3 months ago 113MB import [root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEredis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp] # docker load with tar tail image package

< nginx.tare379e8aedd4d: Loading layer [==================================================>

] 62MB/62MBb8d6e692a25e: Loading layer [= = >] 3.072kB/3.072kBf1db227348d0: Loading layer [= = >] 4.096kB/4.096kB32ce5f6a5106: Loading layer [= = >] 3.584kB/3.584kBd874fd2bc83b: Loading layer [= = >] 7.168kB/7.168kBLoaded image: nginx:latest [root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx latest 605c77e624dd 3 months ago 141MBredis latest 7614ae9453d1 3 months ago 113MBDocker export command

Description: exports the specified container to run or stop as a tar package.

Syntax:

Docker export [OPTIONS] CONTAINER

OPTIONS description:

-o: write the input to a file.

Run a docker redis container using a redis:latest image.

[root@harbor tmp] # docker run-d-name redis redis:latest00bd9bf582ffdf7dc89793252de9b663ce5b685061bb3652d167924270bed423 [root@harbor tmp] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES00bd9bf582ff redis:latest "docker-entrypoint.s …" 3 seconds ago Up 2 seconds 6379/tcp redis

Export a running redis container as a redis.tar.gz package.

[root@harbor tmp] # docker export-o redis.tar.gz redis [root@harbor tmp] # lsnginx.tar nginx.tar.gz redis.tar.gz

Stop the redis container

[root@harbor tmp] # docker stop redisredis

Export a stopped redis container as a redis1.tzr.gz package

[root@harbor tmp] # docker export-o redis1.tar.gz redis [root@harbor tmp] # lsnginx.tar nginx.tar.gz redis1.tar.gz redis.tar.gzDocker import

Description: import content from tar package to mirror docker.

Grammar

Docker import [OPTIONS] file | URL |-[REPOSITORY [: TAG]]

OPTIONS description:

-c: use the docker instruction to create an image

-m: description text at the time of submission

You can specify a URL or-(dash) directly from STDIN. URL can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz) that contains a file system, or a single file on a Docker host. If you specify an archive, Docker will extract it in a container relative to / (root). If you specify a single file, you must specify the full path within the host. To import from a remote location, specify a that starts with the or protocol URI. Http://https://

[root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEredis latest 7614ae9453d1 3 months ago 113MB [root@harbor tmp] # docker import redis1.tar.gz redis:v1sha256:07d6e5a00daa386ed5117d7bf7751f74b46f5831aea69036580cd509bb6781e7 [root@harbor tmp] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEredis v1 07d6e5a00daa 2 seconds ago 109MBredis latest 7614ae9453d1 3 months ago 113MB exports the image docker import https://example.com/exampleimage.tgz through url. I believe you have a better understanding of "how to import and export Docker images". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report