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

Two separate rocker containers mounting same directory - the one terminates the other #415

Open
achamess opened this issue Aug 11, 2020 · 6 comments

Comments

@achamess
Copy link

achamess commented Aug 11, 2020

i have two separate rocker containers with different packages and versions of R.
My data are in a single directory, so when I use docker run I am mounting each container to the same directory. I am directing them to different ports.

The problem I'm noticing is that I can't have both running at the same time. When I log into rstudio in my browser for Container A, Container B gets logged out (back to the Rstudio login screen).

Here are the commands I'm running (password removed):

sudo docker run --gpus all -v "$ARCHIVE":/home -e PASSWORD=**** -d -p 8990:8787 -e ROOT=TRUE --name SC-ml rocker-ml-gpu-single-cell


sudo docker run -v "$ARCHIVE":/home -e PASSWORD=**** -d -p 8994:8787 -e ROOT=TRUE --name escapeR r4-escape

I'm running Ubuntu 18.04

@cboettig
Copy link
Member

Thanks for the report, yes, I've experienced this too. A few points of clarification: getting "logged out" of a session is not the same thing as "the session not running". Even with a single session, you can log out (the new security features in the latest version log you out after 60 minutes of inactivity), but any scripts still running there will keep running. You just cannot be simultaneously logged into both sessions with the same project open when they share working directories.

This is, as far as I know, just how RStudio Server works. Project-specific session info is stored in temporary files in the working directory of the project. Note that you should be able to open different projects in the different containers that share the same volume no problem.

In addition to opening new sessions on new ports when I want to have multiple running interactive sessions, I've found things like the "jobs" panel or using callr's background execution very useful. Sometimes I will also launch multiple terminal sessions within RStudio interface and run R from them :-) .

HTH.

@achamess
Copy link
Author

Thank you for your reply. That helps me understand the issue better. But even when I am in different projects in the two separate containers, it still happens. I closed out of the project in Container A, and stayed in the project in Container B. Still, i could have both open at the same time.

@cboettig
Copy link
Member

Just a note to future self: yes, this seems to have become more of an issue on current RStudio release than it was in the past. May be related to their changes in how RStudio handles its own dotfiles? warrants more investigation. (possibly related: may need more investigation about the filelock issue which seems to have returned as well).

@samuel-colin-foph
Copy link

I there,

I am experiencing a very similar issue when trying to run two rocker-based containers with two separated docker-compose up calls (and the containers being mapped on different ports). They do not share the same mountpoint, but when I try to log-in the second container, I get logged out of the first. If I try to log back again, I get stuck at the logging screen of both, sometimes with an error saying Error: Temporary server error, please try again. I can work on any of the container if I shut down the second one.

Could it be the same issue as described on this ticket or could there some basic step I am missing when running two rstudio containers in parallel?

@cboettig
Copy link
Member

Are you binding to localhost? can you try running a reverse proxy if you are not already? (caddy is really easy to use). I run many containers on the same machine but map them to different subdomains with a reverse proxy and can be logged into them simultaneously no problem.

@samuel-colin-foph
Copy link

Thanks a lot for the tip @cboettig! This works like a charm. For reference, I got inspiration from your instructions on how to use Caddy as well as this Stackoverflow answer to get an https connection and adapted them to my usecase. My docker-compose.yaml therfore looks like this:

version: "3.3"
services:
  caddy:
    image: caddy:2
    depends_on:
      - rstudio-server
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    ports:
      - 80:80
      - 443:443
  rstudio-server: &rstudio-server-1
    image: rocker/rstudio
    environment:
      PASSWORD: ${PASSWORD}
    expose:
      - 8787
    volumes:
      - path_to_my_rstudio_projects:/home/rstudio/Documents
  rstudio-server-2:
    <<: *rstudio-server-1
volumes:
  caddy_data:
  caddy_config:

And my Caddyfile looks like this

rstudio.localhost {
  reverse_proxy rstudio-server:8787
}

rstudio-2.localhost {
  reverse_proxy rstudio-server-2:8787
}

Maybe there is a better way to do this, but this works fine for me now.

Thanks a lot for this amazing project that Rocker is! I don't know how I would work without it 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants