Heredocs in COPY statement throws docker.errors.BuildError: COPY failed: no source files were specified
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the supplied Dockerfile and the client.images.build(path='.', dockerfile='Dockerfile') entry point, then compare the behavior with Docker's inline-file COPY reference documentation. Done means the heredoc COPY example builds successfully through docker-py without the no-source-files BuildError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100