我目前正在从事一个需要密闭云基础设施的项目。因此,所有的人工制品,包括码头图像,都必须离线可用。
看来,docker save和随后的docker import不会产生相同的码头映像。
码头版本: 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以上运行成功!
我的目标是将Docker映像保存为一个*.tar文件,将其移动到另一个服务器,在那里导入映像,并能够像从Internet/ Docker中提取它时一样运行Docker。下面是导致错误的命令序列,所有命令都运行同一台机器。
$ 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'.错误..。它希望得到一个命令,而当直接从Docker中提取时,它不需要命令。还请注意,图像大小是一对不同的MBs。
这是个窃听器还是我漏掉了什么东西?
发布于 2016-04-01 22:10:58
@larsks的评论解决了这个问题。问题是,我使用了错误的函数导入图像。要使用的正确函数是docker load!
下面是一系列适合创建、移动和加载Docker图像的命令。
假设:
10.10.10.10:5000上运行stack/overflow (这个图像不存在!)此图像名称仅用于演示。)开始吧..。
# 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/overflowhttps://stackoverflow.com/questions/36364617
复制相似问题