0

I'm trying to create a Docker image from a file on a Docker host using the Python docker API. The client is running on a different host, so I would like to avoid downloading a file to the client and then uploading it to the Docker host.

This test:

import docker
d = docker.from_env()
print(d.images.client.api.import_image("/data/file.tar", "acme.com/test"))
print(d.images.client.api.import_image("file:///data/file.tar", "acme.com/test"))

produces the following output:

{"status":"Downloading from http://%2Fdata%2Ffile.tar"}
{"errorDetail":{"message":"parse http://%2Fdata%2Ffile.tar: invalid URL escape \"%2F\""},"error":"parse http://%2Fdata%2Ffile.tar: invalid URL escape \"%2F\""}

{"status":"Downloading from file:///data/file.tar"}
{"errorDetail":{"message":"Get file:///data/file.tar: unsupported protocol scheme \"file\""},"error":"Get file:///data/file.tar: unsupported protocol scheme \"file\""}

The Docker daemon 1.13 is running on a Ubuntu 16.04 (Xenial Xerus) VM on an ESXi 6 host. The client is a Docker Python API 2.0.2 running on a physical Windows 10 host.

4

1 回答 1

0

查看Docker 守护程序代码后,我发现 Docker 不支持那里的本地文件,并且总是期望来自 URL 的 HTTP 响应。

因此,我通过 Docker 容器中的 HTTP 服务器公开了该文件并发送了 HTTP URL。

于 2017-06-13T12:38:50.477 回答