82

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?

2 Answers 2

124

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.)

4
  • awesome, will give it a whirl this evening. Thank you!
    – shearn89
    Sep 2, 2015 at 11:07
  • 3
    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 Jan 27, 2016 at 8:50
  • 11
    had to do sudo docker load -i ubuntu_image.docker or it wouldn't work Apr 22, 2016 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? Apr 16, 2018 at 21:56
31

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!

1
  • Thanks! This would have solved my problem too. Unfortunately, the Docker registry v1 is deprecated and was disabled in 2019 (see Registry v1 API Deprecation).
    – loup
    Nov 5, 2020 at 12:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .