Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rocker/rstudio username

I have a docker container rimage, with the docker file based on the rocker project

FROM rocker/rstudio:latest

# Install depencendcies

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y  
   
#copilot 
RUN echo "copilot-enabled=1" | tee -a /etc/rstudio/rsession.conf > /dev/null

RUN apt-get update -qq && apt-get install -y \
      libssl-dev \
      libcurl4-gnutls-dev

I want to run this docker with a user specific username, since multiple users use the same mounted volume (/home/rstudio). Every user gets its own folder with configurations and the configurations are saved for the next use of the container. I start the container using command:

docker run --rm -ti -e USER=name -e PASSWORD=testje -p 8787:8787 -p 8000:8000 rimage

However the following message is returned since lately: Settings by -e USER=<new username> is now deprecated and will be removed in the future. Please do not use the USER environment variable.

What is the new appropriate way to start an rocker/rstudio image with a specific username?

like image 243
tjerkie Avatar asked Sep 02 '26 05:09

tjerkie


2 Answers

A possible solution is the following docker file

FROM rocker/tidyverse:latest

# Accept a build argument for the username and set a default value
ARG DEFAULT_USER=new_user

# Set the environment variable for the username
ENV DEFAULT_USER=${DEFAULT_USER}

# Set up the user
RUN if grep -q "1000" /etc/passwd; then \
        userdel --remove "$(id -un 1000)"; \
    fi; \
    /rocker_scripts/default_user.sh
    

Build it with:

docker build --build-arg DEFAULT_USER=custom_user -t custom_container .

Run it with:

docker run --rm -ti -e PASSWORD=test  -p 8787:8787 -p 8000:8000 custom_container
like image 106
tjerkie Avatar answered Sep 04 '26 16:09

tjerkie


While this may not be what you're looking for, it solved my (similar?) problem (v. 4.4.1):

  1. Add a new user and group on the host machine (say, UID=1337, GID=1337)

  2. Create to-be-mounted-as-home directory owned by new user (say, /some-path/r-home)

  3. Run rocker/rstudio (or derivative) with args -e USERID=1337 -e GROUPID=1337 -v /some-path/r-home:/home/rstudio as described in the image docs: https://rocker-project.org/images/versioned/rstudio.html#userid-and-groupid taking note of the warning:

If these [the two *ID args] are set, ownership of the /home/rstudio directory in the container is updated by the root user. This will also overwrite the ownership of any files that are bind-mounted under the /home/rstudio directory.

like image 24
jensgram Avatar answered Sep 04 '26 15:09

jensgram