57

I'm working in an office where my laptop is internet-connected, but tightly controlled. I am not allowed to install unauthorized software onto it.

My development workstation is mine to do with as I please, but it does not have an internet connection.

Is there any way for me to download Docker images from the hub as a file that I could then sneaker-net to my dev workstation? Similar to how I can download RPMs or Ruby Gems and burn them to CD? Or is the only way of downloading the images using the 'docker pull' command?

88

Short: use the save CLI command.

https://docs.docker.com/engine/reference/commandline/save/


You can pull the image on a computer that have access to the internet.

sudo docker pull ubuntu

Then you can save this image to a file

sudo docker save -o ubuntu_image.docker ubuntu

Transfer the file on the offline computer (USB/CD/whatever) and load the image from the file:

sudo docker load -i ubuntu_image.docker

(On older versions this was just docker load image.docker, see comments for more info.)

  • awesome, will give it a whirl this evening. Thank you! – shearn89 Sep 2 '15 at 11:07
  • 2
    Pass by, realized that they no longer use docker load <image>, instead, use docker load < ubuntu_image.docker instead. docs.docker.com/engine/reference/commandline/load – Lionel Chan Jan 27 '16 at 8:50
  • 11
    had to do sudo docker load -i ubuntu_image.docker or it wouldn't work – John Culviner Apr 22 '16 at 20:36
  • I've got the same setup as @shearn89, after pulling on a local machine using dockertools and moving the file over to the development environment I am getting the error 'cannot load linux image on windows'. Both the local machine and development environments are windows, do you know what about this workflow causes a linux image to be built? – Ryan Haunfelder Apr 16 '18 at 21:56
27

I realize there is already an accepted answer, however I wanted to offer this solution that I think more directly addresses the question asked: "How do I download a Docker Image without using Docker to perform the retrieval?"

I have a similar issue, where my company's policies require me to provide a team with the file(s) (typically by way of URL) that I want to use. They will then perform various scans and audits, and then place the file(s) onto our disconnected development network. I cannot use Docker to retrieve the file, then export it and hand it to that team, so the other answer provided was not an option for me.

Luckily, I found this answer over on StackOverflow, which recommends using a useful tool provided by samalba at GitHub: https://github.com/samalba/docker-registry-debug

Of course, that tool was meant to be built using Docker, and part of the reason I need it is because I don't have open access to Docker :). So, since I didn't have that option, I'll spell out the steps I took here (this is all as of commit 05fffc4344fd6f866f84c403caae3ba81193dd45 from that repo):

$ go get github.com/dustin/go-humanize
$ go build
$ ./docker-registry-debug --help
$ ./docker-registry-debug curlme docker ubuntu

The output of that command is a complete curl command line that can be used to download the file:

# Reading user/passwd from env var "USER_CREDS"
# No password provided, disabling auth
# Getting token from https://index.docker.io
# Got registry endpoint from the server: https://registry-1.docker.io
# Got token: signature=e145911c2e458b3842e4e92c90bbf5bf2c17bd56,repository="library/docker",access=read
curl -i --location-trusted -I -X GET -H "Authorization: Token signature=e145911c2e458b3842e4e92c90bbf5bf2c17bd56,repository="library/docker",access=read" https://registry-1.docker.io/v1/images/ubuntu/layer

Hope this helps someone else!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.