How run docker images without connect to Internet?

2020-06-04 00:10发布

问题:

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?

回答1:

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



回答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.