Downloading docker image for transfer to non-internet-connected machine

Solution 1:

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

Solution 2:

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!