Created
July 5, 2013 10:40
-
-
Save deepak/5933685 to your computer and use it in GitHub Desktop.
Set ENV in Dockerfile with string interpolation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOCKER-VERSION 0.4.8 | |
FROM ubuntu:12.04 | |
# install essentials | |
RUN apt-get install -y -q git | |
# Install rbenv | |
RUN git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv | |
RUN echo '# rbenv setup' > /etc/profile.d/rbenv.sh | |
RUN echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh | |
RUN echo 'export PATH="$RBENV_ROOT/bin:$PATH"' >> /etc/profile.d/rbenv.sh | |
RUN echo 'eval "$(rbenv init -)"' >> /etc/profile.d/rbenv.sh | |
RUN chmod +x /etc/profile.d/rbenv.sh | |
# install ruby-build | |
RUN mkdir /usr/local/rbenv/plugins | |
RUN git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build | |
ENV RBENV_ROOT /usr/local/rbenv | |
ENV PATH "$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" | |
RUN echo $PATH | |
# does not work. PATH is set to | |
# $RBENV_ROOT/shims:$RBENV_ROOT/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
docker run deepak/badruby /bin/sh -c "echo $PATH"
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cat Dockerfile.badruby | docker build -t deepak/badruby -
...
Step 11 : ENV RBENV_ROOT /usr/local/rbenv
---> Running in 57293936038d
---> f48435fd1f71
Step 12 : ENV PATH "$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
---> Running in bac27d8ed4be
---> 0e088f91da43
Step 13 : RUN echo $PATH
---> Running in 80aefab5e4ea
---> 01727253a304
docker logs 80aefab5e4ea
"$RBENV_ROOT/bin:$RBENV_ROOT/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"