I am currently working on a project that requires an airtight cloud infrastructure. Thus all artefacts, including docker images, have to be available offline.
It appears that the docker save
and the subsequent docker import
do not result in an equal Docker image.
Docker version: 1.10.3
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
$ docker pull registry:2
2: Pulling from library/registry
fdd5d7827f33: Pull complete
a3ed95caeb02: Pull complete
a79b4a92697e: Pull complete
6cbb75c7cc30: Pull complete
4831699594bc: Pull complete
Digest: sha256:20f5d95004b71fe14dbe7468eff33f18ee7fa52502423c5d107d4fb0abb05c1d
Status: Downloaded newer image for registry:2
$ docker run -p 5000:5000 -v /data/docker_images:/tmp/registry-dev registry:2
time="2016-04-01T19:11:55Z" level=warning msg="No HTTP secret provided - generated random secret. This may cause problems with uploads if multiple registries are behind a load-balancer. To provide a shared secret, fill in http.secret in the configuration file or set the REGISTRY_HTTP_SECRET environment variable." go.version=go1.5.3 instance.id=af87e7b7-9b56-49a6-bf71-4bd04e141c95 version=v2.3.1
time="2016-04-01T19:11:55Z" level=info msg="redis not configured" go.version=go1.5.3 instance.id=af87e7b7-9b56-49a6-bf71-4bd04e141c95 version=v2.3.1
time="2016-04-01T19:11:55Z" level=info msg="using inmemory blob descriptor cache" go.version=go1.5.3 instance.id=af87e7b7-9b56-49a6-bf71-4bd04e141c95 version=v2.3.1
time="2016-04-01T19:11:55Z" level=info msg="listening on [::]:5000" go.version=go1.5.3 instance.id=af87e7b7-9b56-49a6-bf71-4bd04e141c95 version=v2.3.1
time="2016-04-01T19:11:55Z" level=info msg="Starting upload purge in 45m0s" go.version=go1.5.3 instance.id=af87e7b7-9b56-49a6-bf71-4bd04e141c95 version=v2.3.1
The above run successfully!
My aim is to save the Docker Registry image as a *.tar file, move it to another server, import the image there and will be able to run the Docker Registry as I could when it was pulled from Internet/ Docker Hub. Below is the sequence of commands, all run one the same machine, that led to the error.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
registry 2 83139345d017 3 weeks ago 165.8 MB
$ docker save 83139345d017 > registry.tar
$ docker import registry.tar foo/registry
sha256:8e84e7d07f97825b0ebaa04054f988566bb7b90083ba80caec6398e085adce84
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
foo/registry latest 8e84e7d07f97 3 seconds ago 172.3 MB
registry 2 83139345d017 3 weeks ago 165.8 MB
$ docker run -p 5000:5000 -v /data/tmp:/tmp/registry-dev foo/registry
docker: Error response from daemon: No command specified.
See 'docker run --help'.
Error... It somehow expects a command, whereas when pulled directly from the Docker Hub, it doesn't require a command. Also note that the image sizes are a couple of MBs different.
Is this a bug or do I miss something here?
@larsks comment resolved it. The problem was that I use the wrong function to import the image. The correct function to use is docker load
!
Below is a sequence of commands that are suitable for creating, moving and loading Docker images.
Assumptions:
10.10.10.10:5000
stack/overflow
(This image does not exist! The image name is used for illustration only.) Here we go...
# Pull the image from public Docker Hub
$ docker pull stack/overflow:0.9
# List the images
$ docker images
stack/overflow 0.9 57cbfaed16bf 7 months ago 20.96 MB
# Change the name of the image to match your local Docker Registry address
$ docker tag 57cbfaed16bf 10.10.10.10:5000/overflow:0.9
# Save Docker image
# IMPORTANT: You need to use the "repo/tag" to select the image to be saved, as it otherwise does not save the "repo/tag" information in the tar file!
$ docker save -o overflow.tar 10.10.10.10:5000/overflow:0.9
# Copy the overflow.tar file to the offline environment, which as the Docker Registry running on 10.10.10.10:5000
# Load Docker image
$ docker load -i overflow.tar
# List the images
$ docker images
10.10.10.10:5000/overflow 0.9 38ea67f2e6d8 7 months ago 20.96 MB
# Push the image to the local registry
$ docker push 10.10.10.10:5000/overflow
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.