Closed gowerc closed 5 years ago
Correct, ENV
variables you declare in a root user environment inside the Dockerfile (or as args at build time) are not by default visible to all users. Put them into /etc/environment
to make them globally available:
FROM rocker/tidyverse:3.5.1
ENV CONTAINER=DOCKER_R
RUN echo $CONTAINER >> /etc/environment
Or maybe into usr/local/lib/R/etc/Renviron
if you prefer.
Or /etc/R/
depending on which container you use -- the ones using the R package have that convenience softlink for /etc/R
-> /usr/local/lib/R/etc
which save some typing.
Hi all,
Thanks for the information. For reasons that I don't understand
ENV CONTAINER=DOCKER_R
RUN echo "CONTAINER=$CONTAINER" >> /etc/environment
Does not work for me (should it ?!), however
ENV CONTAINER=DOCKER_R
RUN echo "CONTAINER=$CONTAINER" >> /usr/local/lib/R/etc/Renviron
does work.
Is there anywhere that defines exactly what the differences between these files and the etc/R
directory is ? Also should adding it to /etc/environment
be working ?
You comingle two questions.
The first is about shell init (/etc/environment
) versus R init. It depends on what process read which file for startup. There is some fine print hiding somewhere. But if this does not work, skip it.
The second is about /etc/R
and there is magic. It is just a symlink on systems that have it.
Sure, well at least I have it working now, thank you for your help :)
I am new to docker so I apologies if this is a basic question with an obvious answer.
I can't see to get container environment variables to be made available to users within rocker rstudio.
Dockerfile:
From the command line within the container:
From within Rstudio
(that is a blank line i.e. nothing gets returned)
I tried moving the variable declaration to the /etc/profile and a script within /etc/profile.d/ but neither of these seemed to fix the issue.
(am on windows)