Docker Community Forums

Share and learn in the Docker community.

Dockerfile Run bash file using $PATH from ENV directive


(Huangyingw) #1

Bellowing are part of my Dockerfile, I want to set PATH once with ENV, and in the following *.sh file, they don’t need to re-define the $PATH.
How to achieve this ?
<-------------------
WORKDIR /root/setup/
RUN export CUDA_HOME=/usr/local/cuda
RUN export PATH="/root/anaconda3/bin:$PATH"
RUN export PATH="/usr/local/bin:/opt/local/sbin:$PATH"

RUN /bin/bash -c “source install_anaconda3.sh”
------------------->

Inside install_anaconda3.sh it is:
<-------------------
#!/bin/bash -

echo "path --> $PATH"
bash “./installer/Anaconda3-5.0.1-Linux-x86_64.sh” -u -b
conda upgrade -y --all
------------------->

Then I got following error:
install_anaconda3.sh: line 5: conda: command not found

the print out of path is:
path --> /usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, this prove that the PATH variable is not passed into install_anaconda3.sh


(Sam) #2

ok, where is the .sh file on the path? how did it get there? is it marked executable?

why do you have 4 layers of shells?

run, bin/bash, source, and then inside script bash ?