Docker

How to Download Docker Images for Offline Use?

Docker Hub is the public repository that hosts a large number of Docker images. Docker images are pre-built containers that can be easily downloaded and run on any system. Users can also download the Docker images for offline use. Moreover, they can load the Docker image onto another computer or keep a backup of the Docker image.

This blog will explain the method to download the official Docker image for offline use.

How to Download Docker Images for Offline Use?

To download Docker images for offline use, check out the provided steps:

  • Navigate to Docker Hub.
  • Search for the desired image and copy its “pull” command.
  • Pull the Docker image in the local repository using the “docker pull <image-name>” command.
  • Save the image to file via the “docker save -o <output-file-name> <image-name>” command.
  • Load the image from the saved file using the “docker load -i <output-file-name>” command.
  • Run the Docker image for verification.

Step 1: Choose an Image and Copy its “pull” Command

First, redirect to Docker Hub, and search for the desired Docker image. For instance, we have searched for the “hello-world” image. Then, copy the below-highlighted command:

Step 2: Pull Docker Image

Now, run the copied command in the Windows PowerShell to pull the selected Docker image into the local repository:

docker pull hello-world

Step 3: Save Docker Image to a File

To save a Docker image to the file, utilize the below-listed command:

docker save -o hello-world_image.docker hello-world

Here:

  • docker save” command is used to save the Docker image to the tar archive file.
  • -o” option is utilized to specify the output file. In our case, it is “hello-world_image.docker”.
  • hello-world” specifies the name of the Docker container image to be saved.

This command will save the “hello-world” image to the “hello-world_image.docker” file:

Step 4: Verification

Follow the provided path in your PC to view the output file:

C:\Users\<user-name>

In the below image, the saved output file can be seen, i.e., “hello-world_image.docker”:

Step 5: Load Docker Image from Saved File

Next, write out the following command to load the Docker image from the saved file on the offline PC:

docker load -i hello-world_image.docker

Here:

  • docker load” command is used to load the Docker image from a tar archive file.
  • -i” option is utilized to specify the input file, i.e., “hello-world_image.docker”.

This command will load the “hello-world” image from the “hello-world_image.docker” file:

Step 6: Run Docker Image

Lastly, run the Docker image to verify the installation:

docker run hello-world

The below output indicates that the Docker image has been downloaded and installed successfully for offline use:

We have explained the easiest way to download the official Docker image for offline use.

Conclusion

To download Docker images for offline use, first, search for the desired image on Docker Hub and copy its “pull” command. Then, run the “docker pull <image-name>” command to pull the Docker image in the local repository. After that, save the Docker image to the file via the “docker save -o <output-file-name> <image-name>” command and load it from the saved file using the “docker load -i <output-file-name>” command. Lastly, run the Docker image for verification. This blog explained the method to download the official Docker image for offline use.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.