暗黑模式
Docker Image
Export and Import Image
To export and import Docker images, you can follow these steps:
Exporting a Docker Image
Use the docker save
command to export a Docker image to a tar file.
sh
docker save -o <path to save tar file> <image name>
# Example:
docker save -o my_image.tar my_docker_image:latest
1
2
3
2
3
Importing a Docker Image
Use the docker load
command to import a Docker image from a tar file.
sh
docker load -i <path to tar file>
# Example:
docker load -i my_image.tar
1
2
3
2
3
Example Workflow
Below is an example workflow for exporting and importing a Docker image.
Step 1: Export the Docker Image
sh
docker save -o my_image.tar my_docker_image:latest
1
Step 2: Transfer the tar file (e.g., via SCP, FTP, or USB drive)
sh
scp my_image.tar user@remote_host:/path/to/destination
1
Step 3: Import the Docker Image on the Target Machine
sh
docker load -i /path/to/destination/my_image.tar
1
This process allows you to export a Docker image from one environment and import it into another, making it portable across different systems.