rocker-org / rocker-versioned2

Run current & prior versions of R using docker. rocker/r-ver, rocker/rstudio, rocker/shiny, rocker/tidyverse, and so on.
https://rocker-project.org
GNU General Public License v2.0
390 stars 163 forks source link

Rstudio ENV PASSWORD does not work #733

Closed LizhongLiu-cims closed 7 months ago

LizhongLiu-cims commented 7 months ago

Container image name

rocker/rstudio:4.3.2

Container image digest

No response

What operating system related to this question?

Windows

System information

No response

Question

Hi I try to use the rocker:studio to build my own image, but when I run the image by set up the environment variable ENV PASSWORD = "my_password", it does not work so I can not log in rstudio with the password I set. From the exec env it seems ENV is set up, but somehow the password of the account is not updated to rstudio. I try echo "rstudio:my_passwd" | chpasswd", it works.

Is there any addtional setup needed for the rstudio to read the ENV in the dockerfile? Below is my dockerfile

FROM rocker/rstudio:4.3.2

Copy requirements.txt into the container

COPY requirements.txt /home/rstudio/requirements.txt

Install devtools and other R packages with specific versions

RUN Rscript -e " \ install.packages('devtools', repos='http://cran.rstudio.com/'); \ library(devtools); \ lines <- readLines('/home/rstudio/requirements.txt'); \ for (line in lines) { \ parts <- strsplit(line, '==')[[1]]; \ package <- parts[1]; \ version <- ifelse(length(parts) > 1, parts[2], NULL); \ if (!is.null(version) && nzchar(version)) { \ devtools::install_version(package, version = version, repos = 'http://cran.rstudio.com/'); \ } else { \ install.packages(package, repos = 'http://cran.rstudio.com/'); \ } \ }"

Set the working directory

WORKDIR /home/rstudio

Expose the RStudio port

EXPOSE 8787

Start the RStudio Server

CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize=0"]

eitsupi commented 7 months ago

Please check the document. https://rocker-project.org/images/versioned/rstudio.html#how-to-use

The process of referencing these environment variables is done by the /init command, which is the default command set for the container. Therefore, if the /init command is not executed, nothing will happen.