-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
$PATH
and ${PATH}
should always mean the same thing within a Dockerfile ENV
instruction
#42863
Comments
As the writer of the comment I can confirm this issue. |
Hmm.. I don't see how they should be different, unless the Dockerfile has a Here's echo $PATH
/usr/local/opt/python@3.8/bin:/usr/local/opt/curl/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/usr/local/opt/go/libexec/bin:/Users/sebastiaan/go/bin Dockerfile: FROM ubuntu
ENV FOO=$PATH
ENV BAR=${PATH}
RUN echo $FOO
RUN echo $BAR Building with the classic (non-buildkit) builder; DOCKER_BUILDKIT=0 docker build --no-cache --progress=plain -t issue-42863 .
...
Step 4/5 : RUN echo $FOO
---> Running in 32b290d790bf
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
...
Step 5/5 : RUN echo $BAR
---> Running in 91e3308aae27
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Inspecting the image to verify the expected values are set in the env-var (output formatted with docker image inspect --format "{{ json .Config.Env }}" issue-42863
[
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"FOO=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"BAR=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
] And when running the image: docker run --rm issue-42863 bash -c 'echo $FOO; echo $BAR; echo "env:"; env'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env:
HOSTNAME=3524e0e81718
PWD=/
FOO=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOME=/root
BAR=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHLVL=0
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env Trying the same with BuildKit enabled: DOCKER_BUILDKIT=1 docker build --no-cache --progress=plain -t issue-42863 .
...
#5 [2/3] RUN echo /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#5 sha256:ab3ea588503bb1a7adeb26327ca6bd9314848f25bc1e71603549203d0124cfa2
#5 0.260 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
...
#6 [3/3] RUN echo /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#6 sha256:1e0a5ecab493edb1c4d795d7a165da7d5585d68a20ace07fbaf9caef20c0e527
#6 0.304 /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
... Inspecting the image to verify the expected values are set in the env-var (output formatted with docker image inspect --format "{{ json .Config.Env }}" issue-42863
[
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"FOO=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"BAR=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
] And when running the image: docker run --rm issue-42863 bash -c 'echo $FOO; echo $BAR; echo "env:"; env'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
env:
HOSTNAME=bd538c962aeb
PWD=/
FOO=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOME=/root
BAR=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/bin/env |
Do you have exact steps to reproduce? Does it reproduce with the steps I wrote above? |
closing as this one went stale |
Yes. As provided in the description above. |
Those "roughly" describe steps, but not exact steps (the devil may be in the details) Does the issue reproduce with the steps I wrote above in #42863 (comment) ? |
An interesting comment on this was posted at https://stackoverflow.com/questions/27093612/in-a-dockerfile-how-to-update-path-environment-variable/65119275?noredirect=1#comment131137480_65119275 :
I wonder if that sheds any useful light on the matter. |
@dankirkd I see the original reporter was using "MinGW from Git Bash 2.29.2.windows.2" - are you also running on Windows in a similar environment? If so, then I suspect it's MinGW / MSYS2 that's causing the output to be modified. You can disable that behaviour by setting the |
@thaJeztah - No, I run on a Mac. |
@thaJeztah Hello! To clear up any confusion, I opened this issue "on behalf" of this comment on StackOverflow. I did not experience the issue myself. I was so astonished with the comment that I thought I should file the issue anyway.
@thaJeztah Apart from being astonished and opening the issue, I tried to reproduce it, but I didn't have a Mac, so I tried on Windows, and the issue did not occur. I decided to add this additional info just in case it helped debugging the problem. Sorry if it added more confusion instead 😅 Also, after reading all comments so far, I suggest reopening the issue :) |
@thaJeztah did you run this on a Mac? If so, which version? |
@dankirkd I think the "yes" you said here ended up being ambiguous (because they asked two questions). To me it seems your "yes" refers only to the first question. @dankirkd Can you please explicitly answer again if the issue happens for you when running precisely the steps from their comment? |
Also, @dankirkd, are you still using a Mac Catalina 10.15.5 or do you have a different version now? |
Description
$PATH
and${PATH}
should always mean the same thing within a DockerfileENV
instruction.Steps to reproduce the issue:
Using Mac (Catalina 10.15.5) with Docker v20.10.8:
ENV FOO=$PATH
andENV BAR=${PATH}
bash
on it and checkecho $FOO
andecho $BAR
Describe the results you received:
Observe that both variables have different values. The former has the container
PATH
, while the latter has the host'sPATH
.Describe the results you expected:
Both variables should have the container
PATH
.Additional information you deem important (e.g. issue happens only occasionally):
This does not happen in Docker Desktop for Windows
Docker version 19.03.13, build 4484c46d9d
with MinGW from Git Bash2.29.2.windows.2
.I am filing this issue according to this comment on stackoverflow. I do not have access to a Mac (Catalina 10.15.5).
The text was updated successfully, but these errors were encountered: