39

I have installed docker in a system which has no connection to Internet so to run an image with docker, I had to download a simple image from this and from another system. Then I put this image in my offline system in this path : C:\Users\Public\Documents\Hyper-V\Virtual hard disks

but when I run docker run hello-world in cmd I see this message:

Unable to find image 'hello-world:latest' locally

and tries to download hello-world image form Internet but it has to no connection to the Internet so it field. Now I want to know where I should put my images in to be visible to docker?

helenDeveloper
  • 624
  • 3
  • 8
  • 15
  • https://stackoverflow.com/questions/19234831/where-are-docker-images-stored-on-the-host-machine answers contains a lot of information. Probably you will need follow indications at https://forums.docker.com/t/where-are-images-stored/9794/11 – Rubén Pozo Jan 06 '18 at 08:18
  • do you see the image when you run docker images? If not, you need to create one using the docker build command. – Ajjo Jan 06 '18 at 10:06
  • no, first I download it from gidhub as a zip file but I do not how I can use it in another system which has not access to Internet. my goal is to put it in the destination path for images for docker when I execut `docker run {myImage}` @Ajjo – helenDeveloper Jan 06 '18 at 11:00
  • Hmm! I am not sure about making images from a tar or archive. Why don't you try making an image in a machine with internet access. And then use docker image save to create a tar, docker image load to load it and docker run? Please note that I haven't tried this myself. Just reference from the documentation. – Ajjo Jan 06 '18 at 11:35

3 Answers3

85

You can do it the easy way without messing around with folders, by exporting the docker image from any other machine with access to internet:

  1. pull the image on a machine with internet access.

    $docker pull hello-world
    
  2. save that image to a .tar file.

    $ docker save --output hello-world.tar {your image name or ID}
    
  3. copy that file to any machine.

  4. load the .tar file to docker.

    $docker load --input hello-world.tar
    

Check out: https://docs.docker.com/engine/reference/commandline/image_save/ https://docs.docker.com/engine/reference/commandline/load/#examples

azro
  • 53,056
  • 7
  • 34
  • 70
Yasser
  • 1,058
  • 8
  • 6
  • when I execute `docker save --output hello-world.tar {your image name or ID}` , where the tar file will save? I want the path of it in windows? @Yasser – helenDeveloper Jan 06 '18 at 11:07
  • 1
    Run the command where you want to save it, the tar file is saved to the current working directory. Its docker command, so it behaves the same on the Linux or Windows. – Yasser Jan 06 '18 at 13:48
  • 1
    Thank you! Now I am able to run any images in an offline system @Yasser – helenDeveloper Jan 06 '18 at 16:17
  • 1
    Thanks! Very useful. – Pavel Biryukov Nov 16 '18 at 13:21
  • 1
    Very nice indeed! Beware that using only image ID, the repository and tag name will be removed. See https://stackoverflow.com/questions/43957171/docker-save-load-lose-original-image-repository-name-tag – ktulinho May 13 '22 at 10:15
2

You are trying to start a container using the dockerfile. You need to first build the image from dockerfile. You can do this via

docker build -t < image name > < path >

You will require the internet connection while building the image.

You can check the image in your system using

docker images

Once you build the docker image you can start the container without internet connection using

docker run < image name >

Also you can export the same image using docker save and docker load functionalities.

MB11
  • 610
  • 1
  • 5
  • 16
  • this answer is irrelevant to the question asked – ademg Sep 28 '21 at 09:12
  • 2
    This IS relevant. OP wants to run on a system without internet. He doesn't specify he has to do it all on the offline system. In fact, he got his original image from another system. This solution is a valid alternative to the accepted answer above. – Mark T Mar 04 '22 at 00:04
-1

Docker runs in a client-server architecture environment just almost like git. It can pull resources from the server online with the client on "your machine".

The command $docker pull hello-world requires connection to the server as part of docker itself.

sigur
  • 662
  • 6
  • 21
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/32108550) – harre Jul 02 '22 at 20:39