Heredocs in Dockerfiles dont work and show up as blank inside container when building images
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
building images with the docker SDK for python using Dockerfile's with heredocs show up as blank inside container.
Python code to reproduce
import docker
import os
import json
def build_docker_image():
client = docker.from_env()
# print(json.dumps(client.version(), indent=4))
# print(json.dumps(client.info(), indent=4))
image, _ = client.images.build(path='/Users/wick/DockerTest', platform="linux/amd64",, tag='rocky8-test:latest')
print(f"Image {image.tags[0]} built successfully!")
for log in _:
print(log)
if __name__ == '__main__':
build_docker_image()
Dockerfile used:
FROM rockylinux:8
RUN cat <<EOF > /tmp/test_file
test content
test content
test content
EOF
Results:
/tmp/test_file will be blank.
Additional info:
client.version() output:
{
"Platform": {
"Name": "Docker Desktop 4.28.0 (139021)"
},
"Components": [
{
"Name": "Engine",
"Version": "25.0.3",
"Details": {
"ApiVersion": "1.44",
"Arch": "amd64",
"BuildTime": "2024-02-06T21:14:25.000000000+00:00",
"Experimental": "false",
"GitCommit": "f417435",
"GoVersion": "go1.21.6",
"KernelVersion": "6.6.16-linuxkit",
"MinAPIVersion": "1.24",
"Os": "linux"
}
},
{
"Name": "containerd",
"Version": "1.6.28",
"Details": {
"GitCommit": "ae07eda36dd25f8a1b98dfbf587313b99c0190bb"
}
},
{
"Name": "runc",
"Version": "1.1.12",
"Details": {
"GitCommit": "v1.1.12-0-g51d5e94"
}
},
{
"Name": "docker-init",
"Version": "0.19.0",
"Details": {
"GitCommit": "de40ad0"
}
}
],
"Version": "25.0.3",
"ApiVersion": "1.44",
"MinAPIVersion": "1.24",
"GitCommit": "f417435",
"GoVersion": "go1.21.6",
"Os": "linux",
"Arch": "amd64",
"KernelVersion": "6.6.16-linuxkit",
"BuildTime": "2024-02-06T21:14:25.000000000+00:00"
}
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
Start with the Python reproduction using client.images.build and the provided Dockerfile, then inspect how Dockerfile build input is prepared for the Docker Engine API. Verify the built image's /tmp/test_file contents; done means the heredoc content is preserved instead of appearing blank.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100