Dockerizing shiny-app using a Dockerfile

I want to dockerize a basic shiny-app using a Dockerfile and subsequently running docker build . from the working directory. I am looking at docker docs but cannot really tell the issue with my Dockerfile code.

The shiny-app

## libraries ##

## load data ##
google_data <- data.table(Date = c("01/01/2017",
                          AdjClose = c(1200, 

## ui.R ##

ui <- dashboardPage(
  dashboardHeader(title = "Google Stock Price"),

## server.R ##
server <- function(input, output) { 
  output$google_plot <- renderPlot({ 
    ggplot(google_data, aes(x = Date, y = AdjClose, group = 1)) +

shinyApp(ui, server)

My Dockerfile

FROM quantumobject/docker-shiny

LABEL maintainer = "The Greconomist"

COPY app.R /var/wwww/

WORKDIR /var/www/

RUN  R -e "install.packages('gtable', repos='')"
RUN  R -e "install.packages('data.table', repos='')"
RUN  R -e "install.packages('shinydashboard', repos='')"
RUN  R -e "install.packages('ggplot2', repos='')"


I am using / extending the quantumobject/docker-shiny image found in docker hub. When running the docker build . the build is successful, but unable to to do a docker run [IMAGE].

The result from docker run [IMAGE] is:

Starting pre-service scritps in /etc/my_init.d
*** Running: /etc/my_init.d/
starting rc.local scritps
*** Running: /etc/rc.local
Booting runit daemon...
Process runsvdir running with PID 178
[2018-03-14 09:40:27.933] [INFO] shiny-server - Shiny Server v1.5.6.875 (Node.js v6.10.3)
[2018-03-14 09:40:27.937] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2018-03-14 09:40:27.982] [INFO] shiny-server - Starting listener on

But accessing localhost:3838 give me nothing enter image description here

1 answer

  • answered 2018-03-14 09:46 Ralf Stubner

    The basic usage info for the base image at applies also to the derived image: You have to tell docker that you want port 3838 from the container mapped to the host:

    docker run -p 3838:3838 [IMAGE]

    In addition, you should copy app.R to /srv/shiny-server. BTW, I would move that step to the end of your Dockerfile to make caching of intermediate images possible.