How to load docker container images on offline computer

  • Bagikan

Some of our clients runs their servers behind a lot of security, often with no or restricted access to the public internet.

So how do you pull a container image from an online repository,
like 
Docker Hub, without internet?

Save the container image to a file

Let’s say we want to run the MongoDB database image on our offline server.
First we need to save the container image to a file, so that we can copy it to the offline server.

I’m assuming that you have docker installed on your online and offline computer.
If not, you must install 
docker before continuing!

Lets pull the image to out online computer first by running this command in your command line interface:

docker pull mongo

The above command will download the container image to your online computer.

Illustration to show the container image being pulled.
Illustration to show the container image being pulled.

When the download is complete, you can run this command to verify and find the container image name.

docker images
Illustration to show that the container image is not loaded on the computer.
Illustration to show that the container image is not loaded on the computer.

Now that we have the image, let’s save it to a file using the docker save command. The first line below is to show you the command buildup. The second line is a created example.

docker save -o <output path and filename> <docker image name:tag>docker save -o C:\Temp\mongo-containerimage.tar mongo:latest

Running the command might take some time, so be patient ?

When the command is done, you should see a container file created at the path you specified. ?

Load the image from file

Now to the part where you load the container image on the offline computer.
Firstly, you need to transfer the container file to the computer somehow.

Baca Juga:  Cara Menggunakan Docker Compose untuk Install WordPress

After it has been transferred, we can now use the docker load command.
The first line below is to show you the command buildup. The second line is a created example.

docker load -i <path and filename>
docker load -i C:\Transfer\mongo-containerimage.tar

When the loading is complete, you can now run docker images to verify that it has been loaded.

docker images
Illustration to show the load command, and that the container image has been loaded.
Illustration image to show the load command, and that the container image has been loaded.

Congratulations! The image is now loaded on the offline computer! ?

  • Bagikan