Docker Community Forums

Share and learn in the Docker community.

Run Shiny App with Docker

Hi community,

at my first steps with Docker I followed tutorial instructions of running an R Shiny App via a Docker container. Building the repository via Docker Hub, creating the image with Docker Toolbox and pushing/pulling it worked.

As recommended I used a reference to the Rocker/Shiny repository, so the code in my image looks like below.
By addressing port 3838 and the ‘/App’ directory the web browser only shows the index of the selected path.
So the container is running, but does not start the app in the Shiny environment.

How can I run the app within the container?
Probably it’s mainly a comprehension issue, but several tries and hours of research always led me to this very same point. Therefore, I’m glad for every hint or further explanation.

#get shiny serves plus tidyverse packages image

FROM rocker/shiny-verse:latest

#system libraries of general use

RUN apt-get update && apt-get install -y
sudo
pandoc
pandoc-citeproc
libcurl4-gnutls-dev
libcairo2-dev
libxt-dev
libssl-dev
libssh2-1-dev

#Install R packages that are required

RUN R -e “install.packages(c(‘shinydashboard’,‘shiny’, ‘plotly’, ‘dplyr’, ‘magrittr’))”

#Heatmap related packages

RUN R -e “install.packages(‘gpclib’, type=‘source’)”
RUN R -e “install.packages(‘rgeos’, type=‘source’)”
RUN R -e “install.packages(‘rgdal’, type=‘source’)”

#copy app to image

COPY ./App /srv/shiny-server/App

#When run image and create a container, this container will listen on port 3838

EXPOSE 3838

#allow permission

RUN sudo chown -R shiny:shiny /srv/shiny-server

#run app

CMD ["/usr/bin/shiny-server.sh"]

How did you start your container?

According the documentation, your app should be available at http://localhost:3838/x/, where x is a folder inside the containers /srv/shiny-server/ folder. In your case http://localhost:3838/App/

I would suggest to start your own image like this::

docker run -d -p 3838:3838 \
    -v ./App:/srv/shiny-server/App \
    -v ./shinylog/:/var/log/shiny-server/ \
    your-image-name:your-tage

And then check the logs inside the bind you mapped into the logfolder.

Hi meyay,
you’re right, but as I have to use the Docker Toolbox instead of Docker Desktop for Windows, the localhost address is not available. I solved this by addressing the docker-machine ip in combination with the port, which is in my case:
http://192.168.99.100:3838/App/
The starting command you suggested is what I applied before, too, and when I’m checking the output by the ‘docker ps’ command, I can see that a container is running. So this seems fine to me.
Could you explain a little bit more what you meant by checking the logs inside the bind? I executed the ‘docker logs’ command and this is what I got:

`

I was refering to the folder mounted into the container path /var/log/shiny-server/. If you mounted a folder from your host into the container path, you should be able to see the logs in that particular host folder.

Though, I have no idea how toolbox/desktop do things.