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

Presistent setup of Rocker with docker-compose #464

Closed
bernhardbirkner opened this issue May 26, 2022 · 3 comments
Closed

Presistent setup of Rocker with docker-compose #464

bernhardbirkner opened this issue May 26, 2022 · 3 comments
Labels

Comments

@bernhardbirkner
Copy link

bernhardbirkner commented May 26, 2022

Hello everyone, I am trying to setup a RStudio Server using rocker on my own server to host it via Caddy. I would like the data, packages, and so on to persist on my Server via bind mounts. However I get strange server startup behaviour when trying to mount local folders insider the rocker/verse:4.1.3 conatiner.

My docker-compose currently looks like this.

version: '3.6'
services:
  caddy:
    image: caddy:2-alpine
    restart: always
    volumes:
      - /data/caddy/data:/data
      - /data/caddy/config:/config
      - ./server/Caddyfile:/etc/caddy/Caddyfile
    networks:
      - rstudio_network
    ports:
      - 81:80
      - 444:443


  rstudio:
    image: rocker/verse:4.1.3
    volumes:
      - /data/rstudio/home:/home
      - /data/rstudio/local:/usr/local/lib/R
      - /data/rstudio/lib:/usr/lib/R
      - /data/rstudio/packages:/etc/rstudio
    restart: always
    depends_on:
      - caddy
    environment:
      - PASSWORD=$PASSWORD
      - ROOT=true
      - USERID=$USERID
      - USER=$USER
    networks:
      - rstudio_network
    ports:
      # Debug access 
      - 3000:8787

networks:
  rstudio_network:
    driver: bridge

the folder data/rstudio is fully owned by the user that I pass with env vars to my docker compose setup.

 USERID=1002 PASSWORD="xyz" USER="{PLACEHOLDER}" docker-compose up -d --force-recreate

as

xxx@server:/data$ ls -lah
drwxrwxrwx  6 USER USER 4.0K May 26 17:20 rstudio

what file permissions do I need in order for the mount to succeed?
If I change the bind mount to a docker volume the server starts up good - although I do not prefer using volumes since they might be excidentely deleted ^^

Happy to hear you comments and happy to see how you host rocker via docker-compose.

@eitsupi eitsupi transferred this issue from rocker-org/rocker May 27, 2022
@eitsupi eitsupi added question needs more info Further information is requested labels May 27, 2022
@eitsupi
Copy link
Member

eitsupi commented May 27, 2022

About bind mount, we need detailed information about the host computer running Docker.

In general, it is not recommended to bind-mount the whole /home directory in a container.
For example, I recommend to bind-mount only the folder containing the config file and the working folder as shown below.

services:
  rstudio:
    image: rocker/verse:4
    env_file: .env
    ports:
      - "8787:8787"
    volumes:
      - ./.rstudio_config:/home/rstudio/.config
      - ./works:/home/rstudio/works

I also recommend that you try it in a minimal configuration and share that with us so that we can reproduce the procedure.
Caddy has nothing to do with this issue, right?

@bernhardbirkner
Copy link
Author

bernhardbirkner commented May 27, 2022

Thanks for your answer! Caddy should not have any impact here.
What I am trying to achieve is basically that packages that are installed within the rocker container do not need to be reinstalled after each docker restart. I actually achieved this by mounting the local /usr/local/lib/R/site-library folder into the docker container with the root user / group.
I also figured out that overwriting the R installation via bind mount fails. You can only "override" the site-library

So the correct way would be.

  rstudio:
    image: rocker/verse:4.1.3
    volumes:
      - /data/rstudio/home:/home
      - /data/rstudio/site-library:/usr/local/lib/R/site-library
      - ./rstudio/rserver.conf:/etc/rstudio/rserver.conf
    restart: always
    depends_on:
      - caddy
    environment:
      - PASSWORD=$PASSWORD
      - ROOT=true
      - USERID=$USERID
      - USER=$USER
    networks:
      - rstudio_network
    ports:
      # Debug access 
      - 3000:8787

also overwriting the /home folder works.

Now that you mention it. Where can I find an example of the ./.rstudio_config:/home/rstudio/.config file? Might be interesting for further configs. Other than that I think we can call this closed?

@eitsupi
Copy link
Member

eitsupi commented May 27, 2022

Containers created with docker compose are not destroyed until you explicitly run the docker compose down command, so you do not need to worry about reinstalling libraries.
When restarting Docker, the containers just stop (like docker compose stop command).

And, if you are rebuilding a container from a new image, the R and apt packages are expected to be updated on the new image, so you don't want to inherit the R packages from the old container, do you?

Now that you mention it. Where can I find an example of the ./.rstudio_config:/home/rstudio/.config file? Might be interesting for further configs. Other than that I think we can call this closed?

RStudio configuration files modified on the RStudio GUI are saved in ~/.config/rstudio. (see #103)
In other words, nothing is saved here at first, but when we change the settings on RStudio, the configuration file is saved in this location.
It is useful to be able to make this file persistent, as it would be time-consuming to reconfigure the settings each time the container is rebuilt.

@eitsupi eitsupi removed the needs more info Further information is requested label May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants