2

I launch R studio VM instance from Google console. I install many packages from the R studio. Now once I stop the VM and restart it, the packages get deleted. SO again I have to install the packages afresh.

I got so articles on web which talk about creating an image after installing packages then creating VM on top of it.

But I want to use the same VM everytime.

Somewhere I got to know that this is due to restarting of docker. Can you just tell what changes I should make to the console so that the dockerfile won't get restarted. So that I don't have to install the packages everytime I start the VM.

GalloCedrone
  • 4,869
  • 3
  • 25
  • 41
Vikrant
  • 139
  • 1
  • 12

1 Answers1

1

I believe you are a bit confused by the tools you are using.

First of all if you are running your application on Docker it is normal that each time you exit it you "lose" every change you have done to your machine and a Docker container is not a virtual machine.

If you want to proceed with the docker container solution there are basically these possibilities:

  • If you are interested to preserve the change you have made to the base image (notice that you should follow this each time you want to "save") you could read this Stackoverflow answer.

  • You might want to look at docker volumes if you you want to persist the data in your container. Visit https://docs.docker.com/engine/tutorials/dockervolumes/. The docker documentation is a very good place to start, but also this question can be useful.

  • When you use docker run to start a container, it actually creates a new container based on the image you have specified.

    docker ps -a
    docker start f357e2faab77 # restart it in the background
    docker attach f357e2faab77 # reattach the terminal & stdin
    

However are you sure that the best way to proceed is to run a docker container and not on a normal Google Cloud Plaform instance?

GalloCedrone
  • 4,869
  • 3
  • 25
  • 41
  • Thank you But when I create a VM in google cloud it automatically attaches a docker. Is der any way to stop this. I want to use the persistent disk to behave as normal disk of my laptop/ – Vikrant Mar 19 '18 at 19:03
  • 1
    Just tell me a way to use Rstudio on google cloud the way I use it on my PC. I followed this(http://code.markedmondson.me/launch-rstudio-server-google-cloud-in-two-lines-r/) to install RStudio on VM. The only problem is that the installed R packages get deleted once I restart the VM. – Vikrant Mar 19 '18 at 20:20
  • Since you are not really familiar with Docker at the beginning it could be a bit tricky to understand how it works and how you should proceed to make your changes "persistent". I would suggest you either reading a bit the documentation and the Stackoverflow questions I sent you to understand it better or to go for a normal installation on a virtual machine that you can handle in a easier way. There is this post showing you how to do it step after step https://askubuntu.com/questions/862403/install-the-lastest-version-of-rstudio – GalloCedrone Mar 20 '18 at 08:12