My goal: Create docker container with Shiny app that writes a file to a mounted volume.
Replex: As a minimal reproducible example I created: GitHub - vincentvanhees/rshiny_in_docker_test: Report to test using Rshiny in Docker with mounted volume , which is a Shiny app that has a single button to initiate the writing of a tiny text file to the mounted volume. The container only takes a minute to build and installation steps are in the README.
What works: When launched outside the docker container, directly from RStudio, the app works fine and the file is written after the button is clicked.
Issue: When launched via Docker the app with button are visible, but when the button is clicked the app crashes. No log file is stored inside /var/log/shiny-server.
My own investigation so far: I am using Ubunutu 18.04 and managed to replicate the issue in Ubuntu 20.04 with virtual machine. However my colleague is not able to replicate the issue on his OSx. So, the issue may relate to the operating system and/or docker version. I am using the latest docker version 20.10.12, build e91ed57.
Question: Does anyone here have suggestions on how I can resolve this?
The info below is a copy from what you can also find in the repo (see link above):
# get shiny server and R from the rocker project FROM rocker/shiny SHELL ["/bin/bash", "--login", "-c"] # install R packages required RUN R -e 'install.packages("remotes", \ repos="https://packagemanager.rstudio.com/cran/__linux__/focal/latest"\ )' RUN R -e 'remotes::install_github("vincentvanhees/rshiny_in_docker_test")' # Copy code to run the app to the container RUN mkdir -p /code COPY /code/app.R /srv/shiny-server/ # Change working directory to equal the location of the mounted volume WORKDIR /srv/shiny-server/data # run app CMD ["/usr/bin/shiny-server"]
I am launching the container with:
docker run --rm -it -v ~/:/srv/shiny-server/data/ -p 3838:3838 -u shiny test-app