Docker packages the local image and restores it to other machines

Docker packages the local image and restores it to other machines

1. Use docker images to view all the image files on this machine

2. docker save eb40dcf64078> /root/mydjango-save-1016.tar Save the image as a local file, where eb40dcf64078 is the image id

3. Upload the files saved locally to the server that cannot be pulled. The network is connected. I use the scp command directly here.

4. Use the load method to load the tar file just uploaded

docker load < /root/mydjango-save-1016.tar

5. Use the docker images command on the new machine to view the local image and check whether the image just loaded is loaded. It is found that the image name and tag loaded are both none. Use docker tag eb40dcf64078 django:latest to modify them to the original image name and tag name, where eb40dcf64078 is the images id.

6. Use docker run -itd django:latest to load and verify whether the image can be successfully "run"

Additional knowledge: Docker image import and export, image renaming. Can be used to deploy Docker applications offline

Exporting an Image

Docker images view image id and name

Export using imageId (not recommended)

docker save -o fileName.tar imageId

However, I found a problem that the image exported using imageId has both the repository and name as none when imported. However, when the image is exported using the image name and then imported again, none appears.

The reason for this error is that when docker loads, the image with the same name will be overwritten and the original image will be renamed, resulting in the problem shown in the figure above.

To rename an image:

docker tag [image id] [new image name]:[new image tag]

demo

docker tag 6982b35ff928 zookeeper

Export using imageName (recommended)

docker save -o ./fileName.tar imageName

demo

docker save -o ./portainer.tar portainer/portainer

Importing an Image

docker load -i < ./fileName.tar

demo

The above article about docker packaging local images and restoring them to other machines is all I have to share with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Implementation of Docker packaging image and configuration modification
  • How to use Docker to package and deploy images locally
  • Detailed explanation of how to use Docker to deploy a web project and package it into an image file
  • Using jib to package docker images
  • Detailed explanation of Docker container basic system image packaging
  • Use scripts to package and upload Docker images with one click

<<:  How to call a piece of HTML code together on multiple HTML pages

>>:  js to realize simple shopping cart function

Recommend

SQL to implement time series dislocation restoration case

Table of contents 1. Requirements description 2. ...

HTML+CSS makes div tag add delete icon in the upper right corner sample code

1. Requirements description Display the delete ic...

Some suggestions for HTML beginners and novices, experts can ignore them

Feelings: I am a backend developer. Sometimes when...

Vue component communication method case summary

Table of contents 1. Parent component passes valu...

How to manually build a new image with docker

This article introduces the method of manually bu...

10 SQL statement optimization techniques to improve MYSQL query efficiency

The execution efficiency of MySQL database has a ...

Pitfalls and solutions encountered in MySQL timestamp comparison query

Table of contents Pitfalls encountered in timesta...

Based on the special characters in the URL escape encoding

Table of contents Special characters in URLs URL ...

Docker binding fixed IP/cross-host container mutual access operation

Preface Previously, static IPs assigned using pip...

mysql zip file installation tutorial

This article shares the specific method of instal...

How to add a column to a large MySQL table

The question is referenced from: https://www.zhih...

One line of CSS code to achieve the integration of avatar and national flag

It’s National Day, and everyone is eager to celeb...

Analysis of MySQL data backup and recovery implementation methods

This article uses examples to describe how to bac...