I am trying to get the demo shiny app (that gets created by RStudio when a new shiny project is created) to run in docker. Here is my docker file
FROM rocker/r-ver:4.2.1
RUN R -e "install.packages(c('shiny'), repos = c(CRAN = 'https://cloud.r-project.org'))"
COPY Rprofile.site /usr/lib/R/etc/
EXPOSE 3838
RUN mkdir /root/app
COPY . /root/app
CMD ["R", "-e", "shiny::runApp('/root/app')"]
Here is the result of sudo docker build -t shiny_docker_test .
Sending build context to Docker daemon 6.144 kB
Step 1/7 : FROM rocker/r-ver:4.2.1
---> 16f78a7e7f2d
Step 2/7 : RUN R -e "install.packages(c('shiny'), repos = c(CRAN = 'https://cloud.r-project.org'))"
---> Using cache
---> 26fcb03f5f68
Step 3/7 : COPY Rprofile.site /usr/lib/R/etc/
---> 05f0c40dc1f2
Removing intermediate container f7f5901a9cba
Step 4/7 : EXPOSE 3838
---> Running in 7b03fab3b7c4
---> ff082954ea8c
Removing intermediate container 7b03fab3b7c4
Step 5/7 : RUN mkdir /root/app
---> Running in 6f5c8092dbf6
---> ad54db45dc2a
Removing intermediate container 6f5c8092dbf6
Step 6/7 : COPY . /root/app
---> 12ef70785ab3
Removing intermediate container 8654310a7b4d
Step 7/7 : CMD R -e shiny::runApp('/root/app')
---> Running in 5cf22ee6e1d1
---> 726aa1d72da8
Removing intermediate container 5cf22ee6e1d1
and here is the result of sudo docker run -p 8080:3838 --rm shiny_docker_test
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> shiny::runApp('/root/app')
Error in loadNamespace(x) : there is no package called ‘shiny’
Calls: loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
How can I get this to work?