I'm using Alpine Linux in a container. I have ENV PATH="~/.local/bin:$PATH" \
in my Dockerfile
When logging into the shell I can successfully ls ~/.local/bin
which is the same as ls /root/.local/bin
, the target binary is there.
However which I call the binary directly or which mybin
it won't work. After explicitly add /root/.local/bin
, then it works.
I'm not sure why is this happening, since ~/.local/bin
and /root/.local/bin
are the same.
Any ideas? Thanks!
Edit:
The dup link gave me some idea of what was happening, but I found that wasn't the main cause. Removing quotes won't work still, as the Dockerfile ENV
directive does not do any shell expansion.
It seems the only viable way to do this is to use export &&
in a CMD
directive.
Nor does $HOME
work in ENV
directive.
ENV
, but you have to setHOME
beforehand. Docker won't automatically set it for you. – muru Oct 21 '19 at 07:51