Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide checkpoint function to save underlying RStudio image to docker container registry #123

Open
MarkEdmondson1234 opened this issue Feb 13, 2019 · 2 comments

Comments

@MarkEdmondson1234
Copy link
Collaborator

A lot of issues with keeping persistent packages within containers could be solved if instead of running
docker run for each VM restart, it instead ran docker start if the container already exists. IF all else fails, make a bash script.

Re: bc3d906?diff=split

@MarkEdmondson1234 MarkEdmondson1234 changed the title Allow containers to restart, not use run all the time Allow containers to docker start, not use docker run all the time Feb 13, 2019
@MarkEdmondson1234 MarkEdmondson1234 pinned this issue Feb 14, 2019
@MarkEdmondson1234
Copy link
Collaborator Author

MarkEdmondson1234 commented Feb 14, 2019

This is actually possible just by specifying metadata equal to the key gce-container-declaration but its unsupported API for now:

https://cloud.google.com/compute/docs/containers/configuring-options-to-run-containers

You can see the current meta data schema by starting an instance via gcloud then downloading its metadata

gcloud compute instances create-with-container busybox-vm \
   --container-image docker.io/busybox:1.27 \
   --container-command "/bin/ash" \
   --container-arg="-c" \
   --container-arg="ls -l" \
   --container-env HOME=/home,MODE=test,OWNER=admin

Then in R:

bb <- gce_get_instance("busybox-vm", project = "mark-edmondson-gde", zone = "europe-west3-c")
cat(bb$metadata$items[bb$metadata$items$key == "gce-container-declaration","value"])

which gives:

# DISCLAIMER:
# This container declaration format is not a public API and may change without
# notice. Please use gcloud command-line tool or Google Cloud Console to run
# Containers on Google Compute Engine.

spec:
  containers:
  - args:
    - -c
    - ls -l
    command:
    - /bin/ash
    env:
    - name: OWNER
      value: admin
    - name: HOME
      value: /home
    - name: MODE
      value: test
    image: docker.io/busybox:1.27
    name: busybox-vm
    securityContext:
      privileged: false
    stdin: false
    tty: false
    volumeMounts: []
  restartPolicy: Always
  volumes: []

@MarkEdmondson1234
Copy link
Collaborator Author

MarkEdmondson1234 commented Feb 15, 2019

After lots of brick walls I've come to the conclusion its simply not a good idea to use docker start for users wanting to persist their RStudio settings, so am looking at making it easier to update the Docker image the RStudio is running.

The RStudio templates have been updated to use startup scripts instead of cloud-config, mainly as startup scripts are easier to call instance metadata into. The metadata can be updated and so on reboot the underlying container can be migrated.

To preserve the state of the containers as a user installs and adds data/scripts, I propose a check point system using gce_push_registry() (which could authenticate itself using googleAuthR::gar_gce_auth() and can be passed itself as a running container) which will run on the instance and push the current state of the RStudio image to a registry, change the metadata to point at the new image and load that upon reboot. Possibly on shutdown script? Or via an internal function/RStudio addin.

@MarkEdmondson1234 MarkEdmondson1234 changed the title Allow containers to docker start, not use docker run all the time Provide checkpoint function to save underlying RStudio image to docker container registry Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant