uber-archive / makisu

Fast and flexible Docker image building tool, works in unprivileged containerized environments like Mesos and Kubernetes.
Apache License 2.0
2.41k stars 156 forks source link

Environment variable in ENTRYPOINT is not substituted with its value at runtime #294

Closed antonsergeyev closed 4 years ago

antonsergeyev commented 4 years ago

Describe the bug An environment variable used in ENTRYPOINT is not substituted with its value at runtime.

To Reproduce Assume a dockerfile:

FROM alpine:latest
ENTRYPOINT echo ${MESSAGE}

Build it with docker (works as expected):

docker build -t makisu-echo-docker .
docker run -e MESSAGE=hello makisu-echo-docker
>hello

Build it with makisu (unexpected output):

makisu_build -t makisu-echo .
docker run -e MESSAGE=hello makisu-echo
>${MESSAGE} /bin/sh

Expected behavior I expect ENTRYPOINT to change dynamically with respect to the environment variable. The output above should be "hello".

Additional context I'm using makisu 0.1.12 and docker 19.03.3

ericmeadows commented 4 years ago

This is also an issue that I am having!

Rowern commented 4 years ago

This bug may lie inside the lib/parser/dockerfile/replace_variables.go file but I might be mistaken.

I will take a look at this later this week.

EDIT: Not at all inside the replace_variables file.

Rowern commented 4 years ago

It looks like docker create the following Entrypoint:

[
  "/bin/sh",
  "-c",
  "echo ${MESSAGE}"
]

And makisu:

[
  "echo",
  "${MESSAGE}"
]

EDIT: A simple workaround until this is fixed is to use this syntax for the entrypoint: from the dockerfile ref

Rowern commented 4 years ago

Anothre PR to handle the CMD directive that also needs this mechanism: https://github.com/uber/makisu/pull/323

Rowern commented 4 years ago

@yiranwang52 You can close this I think

yiranwang52 commented 4 years ago

Yes, thanks for fixing this.