Run a Shiny Server with the rocker/shiny and Docker-Compose on Debian or Ubuntu

How to set up Ubuntu to run Docker, a Shiny Server container, with an existing Apache proxy server configuration. This setup will work for a low-volume application. It runs a single container, on a single host.

Install Docker on the host.

sudo apt install

We’ll use docker-compose, the network composition tool. Make a directory for the application:

mkdir shiny
cd shiny 

Next, create this file, docker-compose.yml:

version: '3'
     image: rocker/shiny
     restart: always
       - shinyservers
       - "3838:3838"
       - "/opt/docker/shiny/logs:/var/log/shiny-server"
       - "/opt/docker/shiny/mountpoints/apps:/srv/shiny-server"
     driver: bridge
       driver: default
         - subnet:

Create the directories to save logs and host the apps:

mkdir -p /opt/docker/shiny/logs
mkdir -p /opt/docker/shiny/mountpoints/apps

I like to use names in my configuration, so I added this line to /etc/hosts: shinyservers

My installation is using Apache as a proxy server to connect to Docker containers via the Docker network. Apache runs the SSL/TLS certification. I had an existing virtual host for this domain, and wanted to mount the Shiny server into the /shiny/ path, so I added this line:

ProxyPass "/shiny/" "http://shinyservers:3838/"

I won’t go into the specifics of the proxy server setup. Nginx or most any other web server can work. Likewise, running ShinyProxy is an alternative, as well.

I settled on using Apache because I’m hosting WordPress, and some WordPress examples use Apache .htaccess hacks. So, the containers running WordPress are using Apache, and used it for the host’s proxy as well.

To start the container, go into the shiny/ directory and run this command:

docker-compose up -d

The -d option causes it to run in daemon mode. This also tells the Docker daemon to restart the container when the system reboots.

The first time you run this, Docker will take a minute to download the image.

This diagram shows the Apache proxy and Docker network and container arrangement:

Apache <-> shinyservers network ( <-> shiny container (172.16.240.??)

As a final step, I add a symlink in my home directory, so I can get into the apps/ directory:

ln -s /opt/docker/shiny/mountpoints/apps shiny-apps

Also Read,limits%20on%20concurrent%20usage%20of%20a%20Shiny%20app.

Leave a Reply