Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
minhio opened this issue Jul 1, 2024 · 0 comments

Comments

@minhio
Copy link

minhio commented Jul 1, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant