Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of saving Docker image as a file and importing image from local file

Shulou Source: shulou.com Published: 2022-06-03 01:42:28 09月14日 Update

1. Overview

After we have made the image, we sometimes need to copy the image to another server to use.

There are two ways to achieve the above goals. One is to upload the image to the warehouse (local or public warehouse), but the other server is willing to communicate with the current server LAN without a public network, so if you use the warehouse, you can only build your own private warehouse, which will be described in another article.

If we just want to copy to a small number of other servers, it is obviously not necessary to build a private repository, and it is also a good choice to save the image as a file and upload it to another server and load the image from the file.

You can use the Docker save and Docker load commands to store and load images.

2. Save the image as a file

If you want to save the image as a local file, you can use the Docker save command.

Command format:

1docker save-o the file name to be saved, the image to be saved

First, check the current image list:

1docker p_w_picpaths

For example, here, we save the image of centos6 as the file p_w_picpath.tar:

When you are done, you can see the file through the ls command.

3. Load the image from the file

You can use the Docker load command to load an image from a file.

Command format:

1docker load-input file

Or

1docker load < file name

The image and related metadata information will be imported.

First use the SSH tool to upload the file to another server.

Then load the image with the command:

1docker load < p_w_picpath.tar

After import, you can use the docker p_w_picpaths command to view:

The image of centos6 has been imported successfully.

Tags: Images files commands servers services repositories file names methods formats private good necessary success information just local area LAN tools data purpose Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB NVidia macOS Shulou Tech Info Microsoft