I have to set export PATH=~/.local/bin:$PATH
. As long I do it via docker exec -it <container> bash
manually it works. However, I tried to automate it in my .dockerfile
with:
FROM jupyter/scipy-notebook
RUN conda install --yes -c conda-forge fbprophet
ENV PATH="~/.local/bin:${PATH}"
RUN pip install awscli --upgrade --user
And it seems like ENV PATH="~/.local/bin:${PATH}"
is not having the same effect as I receive that WARNING here. Do you see what I am doing wrong?
WARNING: The scripts pyrsa-decrypt, pyrsa-decrypt-bigfile, pyrsa-encrypt, pyrsa-encrypt-bigfile, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/jovyan/.local/bin' which is not on PATH.
Make use of ENV directive in dockerfile
ENV PATH "$PATH:/home/jovyan/.local/bin"
Hope this helps.
$PATH
is a list of actual directories, e.g., /bin:/usr/bin:/usr/local/bin:/home/dmaze/bin
. No expansion ever happens while you're reading $PATH
; if it contains ~/bin
, it looks for a directory named exactly ~
, like you might create with a shell mkdir \~
command.
When you set $PATH
in a shell, PATH="~/bin:$PATH"
, first your local shell expands ~
to your home directory and then sets the environment variable. Docker does not expand ~
to anything, so you wind up with a $PATH
variable containing a literal ~
.
The best practice here is actually to avoid needing to set $PATH
at all. A Docker image is an isolated filesystem space, so you can install things into the "system" directories and not worry about confusing things maintained by the package manager or things installed by other users; the Dockerfile
is the only thing that will install anything.
RUN pip install awscli
# without --user
But if you must set it, you need to use a Dockerfile ENV
directive, and you need to specify absolute paths. ($HOME
does seem to be well-defined but since Docker containers aren't usually multi-user, "home directory" isn't usually a concept.)
ENV PATH="$HOME/.local/bin:$PATH"
(In a Dockerfile, Docker will replace $VARIABLE
, ${VARIABLE}
, ${VARIABLE:-default}
, and ${VARIABLE:+isset}
, but it doesn't do any other shell expansion; path expansion of ~
isn't supported but variable expansion of $HOME
is.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With