docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Heredocs in COPY statement throws docker.errors.BuildError: COPY failed: no source files were specified

Open minhio opened this issue 1 year ago • 1 comments

Given the the following Dockerfile

FROM alpine

COPY <<-EOT /tmp/hello
    Hello, world!
EOT

and the following Python codes for building the image

import docker

client = docker.from_env()
image, _ = client.images.build(path='.', dockerfile='Dockerfile')

resulted in this error

docker.errors.BuildError: COPY failed: no source files were specified

client version

{
    "Platform": {"Name": "Docker Engine - Community"},
    "Components": [
        {
            "Name": "Engine",
            "Version": "27.0.1",
            "Details": {
                "ApiVersion": "1.46",
                "Arch": "amd64",
                "BuildTime": "2024-06-24T14:57:52.000000000+00:00",
                "Experimental": "false",
                "GitCommit": "ff1e2c0",
                "GoVersion": "go1.21.11",
                "KernelVersion": "5.15.133.1-microsoft-standard-WSL2",
                "MinAPIVersion": "1.24",
                "Os": "linux",
            },
        },
        {
            "Name": "containerd",
            "Version": "1.7.18",
            "Details": {"GitCommit": "ae71819c4f5e67bb4d5ae76a6b735f29cc25774e"},
        },
        {
            "Name": "runc",
            "Version": "1.7.18",
            "Details": {"GitCommit": "v1.1.13-0-g58aa920"},
        },
        {
            "Name": "docker-init",
            "Version": "0.19.0",
            "Details": {"GitCommit": "de40ad0"},
        },
    ],
    "Version": "27.0.1",
    "ApiVersion": "1.46",
    "MinAPIVersion": "1.24",
    "GitCommit": "ff1e2c0",
    "GoVersion": "go1.21.11",
    "Os": "linux",
    "Arch": "amd64",
    "KernelVersion": "5.15.133.1-microsoft-standard-WSL2",
    "BuildTime": "2024-06-24T14:57:52.000000000+00:00",
}

reference docs https://docs.docker.com/reference/dockerfile/#example-creating-inline-files

minhio avatar Jul 01 '24 14:07 minhio

@thaJeztah This is open for nearly one year now. Can anyone please comment?

andy-maier avatar May 30 '25 09:05 andy-maier