grammarly/rocker

Setting PATH in Rockerfile

Closed this issue · 10 comments

When I try to set the path as follows:

ENV PATH /path/to/something:$PATH

rocker does not maintain the old path and sets the PATH to /path/to/something only.

ENV PATH /path/to/something:$PATH

Works in a Dockerfile.

@vroomanj Can you please give a Dockerfile as an example that works with Docker but does not with Rocker?

FROM centos:latest

MAINTAINER Justin Vrooman <vroomanj@egr.msu.edu>

ENV LANGUAGE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV PYTHONIOENCODING UTF-8

RUN yum clean all && \
    yum -y update && \
    yum -y upgrade

RUN yum -y install epel-release \
                   man \
                   which \
                   curl \
                   wget \
                   git \
                   tcsh \
                   sudo \
                   bzip2 \
                   gcc \
                   gcc-c++ \
                   make \
                   openssl-devel \
                   ca-certificates \
                   texlive*

RUN wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
RUN rpm -Uvh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
RUN rm -f rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

RUN fmtutil-sys --all

RUN wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda3-4.0.0-Linux-x86_64.sh
RUN bash Anaconda3-4.0.0-Linux-x86_64.sh -b -p /opt/anaconda3
RUN rm -f Anaconda3-4.0.0-Linux-x86_64.sh

RUN wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda2-4.0.0-Linux-x86_64.sh
RUN bash Anaconda2-4.0.0-Linux-x86_64.sh -b -p /opt/anaconda2
RUN rm -f Anaconda2-4.0.0-Linux-x86_64.sh

ENV PATH /opt/anaconda3/bin:/opt/anaconda2/bin:${PATH}

RUN curl -L https://github.com/krallin/tini/releases/download/v0.8.4/tini > tini && \
    echo '2d05fd37ff5695bdde9478ebaad591ecb13931c2a001bf4548b8f4e79a6a21fe *tini' | sha256sum -c - && \
    mv tini /usr/local/bin/tini && \
    chmod +x /usr/local/bin/tini

RUN pip install --upgrade pip
RUN /opt/anaconda2/bin/pip install --upgrade pip

RUN pip --no-cache-dir install ipykernel && \
    python3 -m ipykernel.kernelspec && \
    /opt/anaconda2/bin/pip --no-cache-dir install ipykernel && \
    python2 -m ipykernel.kernelspec

RUN yum install cmake glibc-devel.i686 glibc-devel -y
RUN mkdir /opt/cling
RUN git clone http://root.cern.ch/git/llvm.git src && \
    cd src && \
    git checkout cling-patches && \
    cd tools && \
    git clone http://root.cern.ch/git/cling.git && \
    git clone http://root.cern.ch/git/clang.git && \
    cd clang && \
    git checkout cling-patches
RUN cd ../../../ && \
    mkdir build && \
    cd build && \
    cmake -DCMAKE_INSTALL_PREFIX=/opt/cling \
          -DLLVM_TARGETS_TO_BUILD=host \
          -DCMAKE_BUILD_TYPE=Debug \
          ../src && \
    make
RUN cd build && \
    make install
ENV PATH /opt/cling/bin:${PATH}
RUN cd src/tools/cling/tools/Jupyter/kernel && \
    pip install -e . && \
    jupyter kernelspec install cling
RUN rm -rf /build /src

ADD . /usr/src/jupyter-notebook
RUN yum -y install nodejs \
                   npm
RUN pip install --no-cache-dir --pre -e /usr/src/jupyter-notebook
RUN pip install --no-cache-dir environment_kernels
RUN /opt/anaconda2/bin/pip install --no-cache-dir environment_kernels

RUN yum -y install zeromq3 \
                   libXrandr \
                   gcc \
                   gcc-c++ \
                   java-1.8.0-openjdk-headless
ENV LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/usr/lib64
RUN pip install --no-cache-dir pyzmq
RUN pip install --no-cache-dir pymatbridge && \
    pip install matlab_kernel && \
    python3 -m matlab_kernel.install

RUN yum -y install liberation-fonts-common \
                   liberation-mono-fonts \
                   liberation-narrow-fonts \
                   liberation-sans-fonts \
                   liberation-serif-fonts
RUN conda install -c r r-essentials

RUN wget -P /etc/yum.repos.d/ https://copr.fedorainfracloud.org/coprs/nalimilan/julia/repo/epel-7/nalimilan-julia-epel-7.repo
RUN yum -y install julia nettle
ENV JULIA_PKGDIR /usr/local/share/julia/site
RUN julia -e 'Pkg.init()' && julia -e 'Pkg.add("IJulia")' && julia -e 'Pkg.add("PyPlot")'
RUN cp -r /root/.local/share/jupyter/kernels/julia-0.4 /usr/local/share/jupyter/kernels/

RUN yum clean all

RUN rm -rf /var/log/*

RUN mkdir -p -m 700 /root/.jupyter/ && \
    echo "c.NotebookApp.ip = '*'" >> /root/.jupyter/jupyter_notebook_config.py

VOLUME /notebooks
WORKDIR /notebooks

EXPOSE 8888

ENTRYPOINT ["tini", "--"]
CMD ["jupyter", "notebook"]

It should break right after the line:

ENV PATH /opt/anaconda3/bin:/opt/anaconda2/bin:${PATH}

@vroomanj can you make it more minimalistic there is only stuff that matters to reproduce the current case?

I think this should work to demonstrate that the original path is lost. Will test when I have a chance.

FROM centos:latest

ENV LANGUAGE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV PYTHONIOENCODING UTF-8

RUN yum clean all && \
    yum -y update && \
    yum -y upgrade

RUN yum -y install epel-release \
                   man \
                   which \
                   curl \
                   wget \
                   git \
                   tcsh \
                   sudo \
                   bzip2 \
                   gcc \
                   gcc-c++ \
                   make \
                   openssl-devel \
                   ca-certificates

RUN wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda3-4.0.0-Linux-x86_64.sh
RUN bash Anaconda3-4.0.0-Linux-x86_64.sh -b -p /opt/anaconda3
RUN rm -f Anaconda3-4.0.0-Linux-x86_64.sh

RUN echo $PATH
ENV PATH /opt/anaconda3/bin:${PATH}
RUN echo $PATH

RUN curl -L https://github.com/krallin/tini/releases/download/v0.8.4/tini > tini && \
    echo '2d05fd37ff5695bdde9478ebaad591ecb13931c2a001bf4548b8f4e79a6a21fe *tini' | sha256sum -c - && \
    mv tini /usr/local/bin/tini && \
    chmod +x /usr/local/bin/tini

Or if you want to be really simple:

FROM centos:latest

RUN echo $PATH
ENV PATH /this/is/a/test:${PATH}
RUN echo $PATH

Thanks for reporting, @vroomanj. We have checked Docker recently and it didn't work with this case. Will find out how they do it and will try to reproduce.

@vroomanj Can you please tell Docker and Rocker versions you have?

# docker version
Client:
 Version:         1.9.1
 API version:     1.21
 Package version: docker-1.9.1-25.el7.centos.x86_64
 Go version:      go1.4.2
 Git commit:      78ee77d/1.9.1
 Built:
 OS/Arch:         linux/amd64

Server:
 Version:         1.9.1
 API version:     1.21
 Package version: docker-1.9.1-25.el7.centos.x86_64
 Go version:      go1.4.2
 Git commit:      78ee77d/1.9.1
 Built:
 OS/Arch:         linux/amd64
# rocker -v
rocker version 1.1.2 - ec7c40b (master) 2016-02-12_12:23_GMT

addressed in #98