Load the docker image to another server by saving it as a file
In our work environment, general images are uploaded to the image repository (local or public warehouse) and downloaded to the server when needed. If the server does not have access to the Internet and there is no private warehouse, we need to save the image as a file and upload it to the server and load the image to use it.
1. Save the image as a file
Command:
# docker save-help
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o,-- output string Write to a file, instead of STDOUT
Example:
Docker images | grep centos# to view the images to be saved
Centos latest 0f3e07c0138f 2 months ago 220MB
Docker save-o centos.tar centos# saves the image as a centos.tar file, which can be viewed by ls.
2. Load the file into the image
Command:
Docker load-help
Usage: docker load [OPTIONS]
Load an image from a tar archive or STDIN
Options:
-I,-input string Read from tar archive file, instead of STDIN
-Q,-- quiet Suppress the load output
Example: upload the file we saved just now to the server we need
Docker load-I centos.tar
Or:
Docker load