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 Dockerfiles dont work and show up as blank inside container when building images #3246

Open
brandon-wick opened this issue Apr 8, 2024 · 0 comments

Comments

@brandon-wick
Copy link

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"
}
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