How to load a Docker image from a tar file
Asked Answered
A

4

96

I have installed Docker for Windows. I have downloaded HDP_2.5_docker.tar from http://hortonworks.com/downloads/#sandbox which is a 10 GB file.

How can I load an image tar file? I have tried this command:

docker import HDP_2.5_docker.tar
Atheistic answered 14/11, 2016 at 5:20 Comment(0)
D
135

You can use docker load

Usage:  docker load [OPTIONS]

Load an image from a tar archive or STDIN

Git bash console:

docker load < HDP_2.5_docker.tar

Windows cmd:

docker load -i windowsservercore.tar
Ditto answered 14/11, 2016 at 5:43 Comment(6)
thnx, but i m getting The system cannot find the file specified.Atheistic
@Naveen you need to run this command in folder where HDP_2.5_docker is located (or use path for HDP_2.5_docker file). Also check whether file extension is not tar.gz by default the name of downloaded file should be HDP_2.5_docker.tar.gzDitto
This doesn't work for me in cmd.exe env: docker.exe load < windowsservercore.tar, returns requested load from stdin, but stdin is empty. The following one works though: docker.exe load -i windowsservercore.tar. I think the answer is incorrect (question is marked with "windows") and should be fixed.Sharl
@Sharl Thanks for comment! You are probably right cause I dont use cmd but "git bash" console. I added your point to answer to make it more visible for others.Ditto
I may be late here but it might help someone.. for windows platform its -i flag!Amitie
Or just use docker load -i <file> in both Windows and Linux (bash)...Pape
D
25

Firstly, put the tar file under your user folder: i.e: C:\Users\yourName\xxx.tar

Secondly, run the Docker load CMD:

docker load -i xxx.tar

After it is done, we could see the file is loaded as Docker images by running CMD:

docker images
Dimond answered 9/5, 2017 at 4:51 Comment(2)
The accepted answer from VladoDemcak gave me the error requested load from stdin, but stdin is empty, but this method worked. ThanksUnchartered
Thank you, that is the correct location to place a docker image.Hake
M
17

you can do:

docker image import file.tar images_name:image_tag
Meseems answered 28/12, 2020 at 10:34 Comment(2)
I tried this way since I wanted to provide a docker image name and tag name but when I tried to run the docker image it was throwing an error. Whereas using docker load worked fine when running the docker image.Roguery
tried this and it did import the image, but I saw the same issue as @AmitPathak trying to run it. Learned that docker load and docker import have subtle but important distinctions #36925761. The .tar created from docker save provides a ton of context that is lost when imported with docker import -- using docker load -i instead maintains that context and allows the image to be run directlySiloam
R
16

Load the desired docker file, assuming you are in the same directory as the tar file, you can use -

$ docker load -i filename.tar

On successful import, you will see a success message along with the image ID

Check in the docker images for the image ID that you just received:

docker images

You will see the docker loaded successfully in the docker images list. However, there is one thing worth mentioning in case you might get confused; the date reflected in the command output might reflect the date when docker is created. Assuming, docker got created 5 days ago then the same will be shown in the output. Better way to confirm if your docker is loaded or not is to check for the image ID or repo and tag name (if you know).

You can finally run the docker using the command -

$ docker run -it image-ID
Roguery answered 23/11, 2021 at 4:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.