Stéphane
Stéphane

Reputation: 1334

RStudio in docker image does not deal with some librairies

I have a problem to use the docker rstudio-image rocker/rstudio proposed on https://www.rocker-project.org/ (docker containers for R). Since I am a beginner with both docker and RStudio, I suspect the problem comes from me and does not deserve a bug report:

I don't know whether xml2 is on the image but the file libxml-2.0.pc does exist on my laptop in the directory /opt/local/lib/pkgconfig and pkg-config is in /opt/local/bin. So I tried linking these pkg paths when running the image (to see what happen when I play with the image environment in RStudio), adding options -v /opt/local/lib/pkgconfig:/home/rstudio/lib/pkgconfig -v /opt/local/bin:/home/rstudio/bin to the run command. But it doesn't work: for some reason I don't see the content of lib/pkgconfig in RStudio...

Also the RStudio instance does not accept root/sudo commands so I can't use tools such as apt-get in the RStudio terminal

so, what's the trick ?

Upvotes: 0

Views: 756

Answers (1)

lmtx
lmtx

Reputation: 5576

Libraries on your laptop (the host for docker) are not available for docker containers. You should create a custom image with required libraries, create a Dockerfile like this:

FROM rocker/rstudio

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
    libxml2-dev # add any additional libraries you need

CMD ["/init"]

Above I added the libxml2-dev but you can add as many libraries as you need.

Then build your image using this command (you need to execute below command in directory there you created Dockerfile):

docker build -t my_rstudio:0.1 .

Then you can start your container:

docker run -d -p 8787:8787 -e DISABLE_AUTH=true --name rstudio my_rstudio:0.1

(you can add any additional arguments like -v to above).

Upvotes: 3

Related Questions