Using ENV variables in daemonized Docker running RStudio

I am able to set up a Dockerfile with default ENV variables that I can then configure when running my docker container, e.g. in a Dockerfile I have the lines:

RUN git config --global $USERNAME
RUN git config --global $EMAIL

Great. When I launch an interactive session:

  • Docker Container Failed to Run
  • Is there any way to compile and statically link ruby libs for Docker?
  • Docker pull error
  • How to see the log information in running docker daemon?
  • How do I run a shell script and jar application in a docker image?
  • docker is using the v1 registry api when it should use v2
  • docker run -it --env USERNAME="Carl" --env myimage /bin/bash

    I can then issue the command git config --list and see that git is configured to use the values I provided on the command line instead of the defaults.

    However, my Dockerfile is also configured to run an RStudio server that I can then log into in the browser when running the image in Daemon mode:

    docker run -d -p 8787:8787 --env USERNAME="Carl" --env cboettig/ropensci-docker

    I go to localhost:8787 and log in to RStudio which all works as expected, start a new “Project” with git enabled, but then RStudio cannot find my git name & email. I can open the shell from the RStudio menu and run git config --list or echo $USERNAME and I just get a blank value. Why does this work for /bin/bash but not from RStudio and how do I fix it?

  • Sandbox command execution with docker via Ajax
  • Docker local private registry cross region setup
  • Is it possible to use vagrant + aws provider + docker provider?
  • Download logs from docker containers
  • How to export a project from IBM Bluemix PaaS to anywhere else as a Docker?
  • How can I see which file(s) caused a Dockerfile `COPY` statement to invalidate the cache?
  • One Solution collect form web for “Using ENV variables in daemonized Docker running RStudio”

    Your git config is set on /.gitconfig. This config file is for root user. You need to set git config for rstudio user because rstudio run on rstudio user. Below command is a temporary solution.

    docker run -it -p 8787:8787 --env USERNAME="Carl" --env cboettig/ropensci-docker bash -c "cp /.gitconfig /home/rstudio; /usr/bin/supervisord"

    It works!


    Another solution is writing Dockerfile is based on cboettig/ropensci-docker. Below is sample Dockerfile.

    FROM cboettig/ropensci-docker
    RUN cp /.gitconfig /home/rstudio
    CMD ["/usr/bin/supervisord"]
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.