Skip to content

Instantly share code, notes, and snippets.

What would you like to do?

Shiny Server Pro in Docker

This is a Dockerfile for Shiny Server Pro on Ubuntu 14.04. It is based on the rocker-org Shiny image, except that it builds on Ubuntu instead of Debian, and installs Shiny Server Pro instead of Shiny Server.

This Dockerfile also installs some examples from the an old commit of the shiny-examples repo. The purpose of this Dockerfile is to run specific examples that require Shiny Server Pro, and currently can't be run on

NOTE: Building the Docker image requires compiling dplyr, which can consume a lot of memory. If you're running this on a VM, you may need to enable swap for the VM.


To build (assuming you're in this directory):

docker build -t ssp-examples .

To run a temporary container with Shiny Server Pro:

docker run --rm -p 3838:3838 ssp-examples

Then you can visit examples at (e.g.):

(If using boot2docker, visit A full list of the examples is at the shiny-examples repo.

To expose a directory on the host to the container use -v <host_dir>:<container_dir>. The following command will use /srv/shinylog on the host as the directory for logs. Note that if the directories on the host don't already exist, they will be created automatically.

docker run --rm -p 3838:3838 \
    -v /srv/shinylog/:/var/log/ \

In a real deployment scenario, you will probably want to run the container in detached mode (-d) and listening on the host's port 80 (-p 80:3838):

docker run -d -p 80:3838 \
    -v /srv/shinylog/:/var/log/ \
FROM ubuntu:14.04
MAINTAINER Winston Chang ""
# =====================================================================
# R
# =====================================================================
# Need this to add R repo
RUN apt-get update && apt-get install -y software-properties-common
# Add R apt repository
RUN add-apt-repository "deb $(lsb_release -cs)/"
RUN apt-key adv --keyserver --recv-keys E084DAB9
# Install basic stuff and R
RUN apt-get update && apt-get install -y \
vim-tiny \
less \
wget \
r-base \
r-base-dev \
# =====================================================================
# Shiny Server Pro
# =====================================================================
RUN apt-get install -y \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
# Download and install libssl 0.9.8
RUN wget --no-verbose && \
dpkg -i libssl0.9.8_0.9.8o-4squeeze14_amd64.deb && \
rm -f libssl0.9.8_0.9.8o-4squeeze14_amd64.deb
# Download and install shiny server pro
RUN wget -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget "$VERSION-amd64.deb" -O ssp-latest.deb && \
gdebi -n ssp-latest.deb && \
rm -f version.txt ssp-latest.deb
RUN echo "password" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "manager"
RUN echo "password" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "sales1"
RUN echo "password" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "sales2"
#RUN echo "kimpass" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "kim"
#RUN echo "sampass" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "sam"
#RUN echo "johnpass" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "john"
#RUN echo "kellypass" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "kelly"
#RUN echo "benpass" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "ben"
#RUN echo "joepass" | /opt/shiny-server/bin/sspasswd /etc/shiny-server/passwd "joe"
RUN R -e "install.packages(c('shiny', 'rmarkdown'), repos='')"
COPY /usr/bin/
CMD ["/usr/bin/"]
# =====================================================================
# Shiny examples
# =====================================================================
# Get examples from git repo. This downloads the files from the commit just
# before Garrett deleted them from the repo:
RUN cd /srv/shiny-server && \
wget && \
unzip && \
rm && \
mv shiny-examples-230acb1990f1ea6049885837eac8e58ed8405f80/* . && \
rm -rf shiny-examples-230acb1990f1ea6049885837eac8e58ed8405f80
# Packages needed for specific examples
#RUN R -e "install.packages(c('ggplot2', 'lubridate', 'dplyr', 'RSQLite'), repos='')"
RUN R -e "install.packages(c('ggplot2', 'lubridate'), repos='')"
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
# Specify the authentication method to be used.
# Initially, a flat-file database stored at the path below.
auth_passwd_file /etc/shiny-server/passwd;
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location / {
required_user manager sales1 sales2;
# Only up tp 20 connections per Shiny process and at most 3 Shiny processes
# per application. Proactively spawn a new process when our processes reach
# 90% capacity.
utilization_scheduler 20 .9 3;
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
# When a user visits the base URL rather than a particular application,
# an index of the applications available in this directory will be shown.
directory_index on;
# Make sure the directory for individual app logs exists
mkdir -p /var/log/shiny-server
chown shiny.shiny /var/log/shiny-server
exec shiny-server >> /var/log/shiny-server.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment