Open 2533245542 opened 3 years ago
docker ....all other arguments... -w /foo container
will start in /foo
so a common paradigm is -v $PWD:/mnt -w /mnt
which first brings the current directory "inside" as /mnt
via -v
and then starts there via -w
.
docker ....all other arguments... -w /foo container
will start in/foo
so a common paradigm is-v $PWD:/mnt -w /mnt
which first brings the current directory "inside" as/mnt
via-v
and then starts there via-w
.
Thanks for the help! I used docker-compose
to create the container so I cannot directly use your answer. Do you have any idea to do that in a docker network? Here is the part RStudio container in my docker-compose.yml
file and app
is the container name of the RStudio.
app:
build:
context: ./src/app
environment:
PASSWORD: "${RSTUDIO_PASSWORD}"
volumes:
- ./src/app/workspace:/home/rstudio/workspace
ports:
- "8787:8787"
depends_on:
- api
networks:
default:
aliases:
- app
Maybe this can help: https://stackoverflow.com/questions/40248908/context-or-workdir-for-docker-compose
Problem solved. This line of code was added to the docker file.
RUN echo "setwd(\"/home/rstudio/workspace/\")" > ~/../home/rstudio/.Rprofile #set up working diretory
this works but how can we set the working directory Files
pane on the right side? It defaults to the /home/user
directory where there is an rstudio
folder with kitematic
subfolder in it
These days we are using this in another setting (and I am a bystander here, someone else worked this out):
USER rstudio
ENV EDITOR_FOCUS_DIR "/home/rstudio/workspace"
RUN mkdir -p "$EDITOR_FOCUS_DIR"
There may be additional documentation in some places...
These days we are using this in another setting (and I am a bystander here, someone else worked this out):
USER rstudio ENV EDITOR_FOCUS_DIR "/home/rstudio/workspace" RUN mkdir -p "$EDITOR_FOCUS_DIR"
There may be additional documentation in some places...
Tried this, no error when building the image but had an error when running the container:
s6-mkdir: warning: unable to mkdir /var/run/s6: Permission denied
when running the container.
Dockerfile:
FROM rocker/verse:3.6.1
USER rstudio
ENV EDITOR_FOCUS_DIR "/home/rstudio/workspace"
RUN mkdir -p "$EDITOR_FOCUS_DIR"
Build command: docker build -t rstudio_test .
Run command: docker run -d -p 8787:8787 -e PASSWORD=yourpasswordhere rstudio_test
The good news is that the error disappeared when commenting USER rstudio
, but the bad news is that the file pane is still defaulted to be /home/rstudio
rather than /home/rstudio/workspace
Hello,
I used RStudio a lot but I am pretty new to rocker and Docker.
Currently, when starting the RStudio in Docker, it defaults to point to /home/rstudio as working directory.
I am wondering if there is a way to set a customized working directory such that when starting up, RStudio goes to the customized working directory directly?
I tried adding this to the docker file to change the default working directory of RStudio but it didn't work.
RUN echo "setwd(\"~/../home/rstudio/workspace/\")" > ~/.Rprofile #set up working diretory