Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing packages for Rstudio Docker

Tags:

docker

rstudio

I'm trying to use Rstudio on a DigitalOcean server using the Rstudio docker. Since my experience with linux servers is limited, it's been a bit of a challenge for me.

I'm able to get Rstudio up and running with:

docker run -dp 8787:8787 -v /root:/home/rstudio/ -e ROOT=TRUE rocker/hadleyverse

However, I'd like to be able to shut down the server and save it to a snapshot when I'm not using it, but not have to re-install packages each time I do so.

Using the the docker documentation on updating an image, I am able to create a container, install packages on that container, and then commit the changes:

docker run -t -i rocker/hadleyverse /bin/bash
install.r randomForest
exit
docker commit \<CONTAINER_ID> michael91/ms:v1

However, once I make the commit, I am unable to run the updated image properly. I try and run it as follows:

docker run -dp 8787:8787 -v /root:/home/rstudio/ -e ROOT=TRUE michael91/ms:v1

When I do so, Rstudio server is not activated, as it is when I run the original rocker/hadleyverse version. I've tried making commits with and without installing packages; either way it doesn't seem to work. Obviously I'm doing something incorrectly, but I'm not sure what. If anyone could offer me some guidance, I'd really appreciate it.

Edit: Thanks a lot VonC; that did the trick.

like image 553
micsadow Avatar asked Apr 26 '15 13:04

micsadow


1 Answers

It could be because the new committed image has lost its CMD directive that was present in rocker-org/rocker/rstudio/Dockerfile#L58.

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d /supervisord.conf"]

Try and create a new Dockerfile:

FROM michael91/ms:v1
## Add RStudio binaries to PATH
ENV PATH /usr/lib/rstudio-server/bin/:$PATH 
ENV LANG en_US.UTF-8
EXPOSE 8787

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

And build it as michael91/ms:v2.

Then see v2 works better than v1 when it comes to activating RStudio:

docker run -dp 8787:8787 -v /root:/home/rstudio/ -e ROOT=TRUE michael91/ms:v2
like image 109
VonC Avatar answered Sep 17 '22 17:09

VonC