I want to install miniconda in ubuntu docker image for a non-root user. So far the installation part is successful but I cannot add the path of conda to the environment variable $PATH of that user. I tried to achieve that with docker ENV. Here is my Dockerfile
FROM ubuntu:20.04
RUN apt-get update && apt-get install -y openssh-server sudo
RUN useradd -rm -d /home/devp -s /bin/bash -g root -G sudo -u 1000 devp && \
echo 'devp:devp11' | chpasswd && \
adduser devp sudo
WORKDIR /home/devp
USER devp
RUN wget \
https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& mkdir ~/.conda \
&& bash Miniconda3-latest-Linux-x86_64.sh -b \
&& rm -f Miniconda3-latest-Linux-x86_64.sh
ENV PATH=/home/devp/miniconda3/bin:${PATH}
ARG PATH=/home/devp/miniconda3/bin:${PATH}
#RUN conda env create --quiet -n env1 --file env1.yml
USER root
RUN mkdir /var/run/sshd
RUN service ssh start
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]
I ran docker with docker run --name img -p 10022:22 -d img:tag
For my root user, $PATH is overridden
/home/devp/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
For my non-root user, $PATH is not overridden when I ssh devp@x.x.x.x -p 10022 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
I have 2 questions:
- How can I override
$PATHfor non-root user? - Why
ENVdoes not work for non-root user?