Docker pull is the basic command for using Docker images. It works most of the time but sometimes it freezes in the middle of the download. Lots of people have raised issues about this with hacks that involve killing a process or restarting the docker-machine several times.
All these hacks aren't an issue with small image sizes like the alpine distribution or an nginx image but, what about the large images? Images that weight like 500 MB or 2 GB?
These hacks aren't useful because they involve downloading large layers over and over again.
A better workaround is to download the images manually and load them to the docker-machine. This is a much better solution as the manual download has much lower chances to fail than restarting the docker-machine hoping that docker pull starts working.
To download a docker image manually, there is a script called 'download-frozen-image-v2.sh' in the Moby project that lets us do that:
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
The Moby Project
Moby is an open-source project created by Docker to enable and accelerate software containerization.
It provides a "Lego set" of toolkit components, the framework for assembling them into custom container-based systems, and a place for all container enthusiasts and professionals to experiment and exchange ideas Components include container build tools, a container registry, orchestration tools, a runtime and more, and these can be used as building blocks in conjunction with other tools and projects.
Moby is an open project guided by strong principles, aiming to be modular, flexible and without too strong an opinion on user experience It is open to the community to help set its direction.
- Modular: the project includes lots of components that have well-defined functions and APIs that work together.
- Batteries included but swappable: Moby includes enough components to build fully featured container system, but its modular architecture ensures that most of…
This script only needs three things installed:
To use the script we only need to specify the image to download and the location relative to the current:
$ ./download-frozen-image-v2.sh "example" hello-world:latest
In this example we are downloading the image "hello-world:latest" in the "example" directory.
Note: be sure to specify the version tag. If not specified, the script will return Not Found (404)
This will download several files into the "example" directory:
- repositories file
- json with details of the image
- folder for each layer in the image
The only thing next to do is load it into the docker-machine. The script outputs the command necessary to do it:
$ tar -cC 'example' . | docker load af0b15c8625b: Loading layer [==================================================>] 977B/977B Loaded image: hello-world:latest
Congratulations! You have pulled a docker image without the docker pull command!