• This repository has been archived on 22/Feb/2022
  • Stars
    star
    220
  • Rank 180,422 (Top 4 %)
  • Language
    HTML
  • Created almost 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Docker for Shiny Server

This is a Dockerfile for Shiny Server on Debian stable. Dockerfiles building on specific versions of R are now available as tags. These images are based on the corresponding r-ver image. You can request a specific R version using the appropriate tag, e.g. rocker/shiny:3.3.2.

For documentation for R >= 4.0.0, for images r-ver, rstudio, tidyverse, verse, geospatial, shiny, and binder, please see the rocker-versioned2 repository`.

Usage:

To run a temporary container with Shiny Server:

docker run --rm -p 3838:3838 rocker/shiny

To get specific version of R with your shiny image (e.g. 3.4.4):

docker run --rm -p 3838:3838 rocker/shiny:3.4.4

Developer Notes

  • avoid apt-get install r-cran-* on this image stack. The requested R version and all R packages are installed from source in the version-stable stack. Installing R packages from apt (e.g. the r-cran-* packages) will install the version of R and versions of the packages that were built for the stable debian release (e.g. debian:stretch), giving you a second version of R and different packages. Please install R packages from source using the install.packages() R function (or the install2.r script), and use apt only to install necessary system libraries (e.g. libxml2). If you would prefer to install only the latest verions of packages from pre-built binaries using apt-get, consider using the r-base stack instead. See rocker-versioned README for details on extending these images.

shiny-verse

You can use rocker/shiny-verse image stack instead if you'd like tidyverse packages pre-installed on your instance of shiny.

Connecting app and log directories to host

To expose a directory on the host to the container, use -v <host_dir>:<container_dir>. The following command will use one /srv/shinyapps as the Shiny app directory and /srv/shinylog as the directory for Shiny app 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/shinyapps/:/srv/shiny-server/ \
    -v /srv/shinylog/:/var/log/shiny-server/ \
    rocker/shiny

If you have an app in /srv/shinyapps/appdir, you can run the app by visiting http://localhost:3838/appdir/. (If using boot2docker, visit http://192.168.59.103:3838/appdir/)

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/shinyapps/:/srv/shiny-server/ \
    -v /srv/shinylog/:/var/log/shiny-server/ \
    rocker/shiny

Warnings

In the logs, you may see a note that shiny is running as root. To run as a regular user, simply set the user in your Docker run command, e.g.

docker run --user shiny -p 3838:3838 --rm rocker/shiny

Logs

The Shiny Server log and all application logs are written to stdout and can be viewed using docker logs.

The logs for individual apps are still kept in the /var/log/shiny-server directory, as described in the Shiny Server Administrator's Guide. If you want to avoid printing the logs to STDOUT, set up the environment variable APPLICATION_LOGS_TO_STDOUT to false (-e APPLICATION_LOGS_TO_STDOUT=false).

With docker-compose

This repository includes an example docker-compose file, to facilitate using this container within docker networks.

To run a container with Shiny Server:

docker-compose up

Then visit http://localhost (i.e., http://localhost:80) in a web browser. If you have an app in /srv/shinyapps/appdir, you can run the app by visiting http://localhost/appdir/.

To add a Shiny app:

  1. Uncomment the last line of docker-compose.yml.
  2. Place the app in mountpoints/apps/the-name-of-the-app, replacing the-name-of-the-app with your app's name.

If you have an app in mountpoints/apps/appdir, you can run the app by visiting http://localhost/appdir/. (If using boot2docker, visit http://192.168.59.103:3838/appdir/)

Logs

The example docker-compose file will create a persistent volume for server logs, so that log data will persist across instances where the container is running. To access these logs, while the container is running, run docker exec -it shiny bash and then ls /var/log/shiny-server to see the available logs. To copy these logs to the host system for inspection, while the container is running, you can use, for example, docker cp shiny:/var/log/shiny-server ./logs_for_inspection.

Detached mode

In a real deployment scenario, you will probably want to run the container in detached mode (-d):

docker-compose up -d

Custom configuration

To add a custom configuration file, assuming the custom file is called shiny-customized.config, uncomment the line

COPY shiny-customized.config /etc/shiny-server/shiny-server.conf

in the Dockerfile, and then run docker-compose build shiny to rebuild the container. Inline comments above that line in the Dockerfile provide additional documentation.

Trademarks

Shiny and Shiny Server are registered trademarks of RStudio, Inc. The use of the trademarked terms Shiny and Shiny Server and the distribution of the Shiny Server through the images hosted on hub.docker.com has been granted by explicit permission of RStudio. Please review RStudio's trademark use policy and address inquiries about further distribution or other questions to [email protected].

More Repositories

1

rocker

R configurations for Docker
Shell
1,446
star
2

rocker-versioned2

Run current & prior versions of R using docker. rocker/r-ver, rocker/rstudio, rocker/shiny, rocker/tidyverse, and so on.
Shell
402
star
3

rocker-versioned

Run current & prior versions of R using docker
Dockerfile
297
star
4

geospatial

Docker-based Geospatial toolkit for R, built on versioned Rocker images
Dockerfile
111
star
5

binder

Template for RStudio on Binder / JupyterHub
Dockerfile
69
star
6

ml

experimental machine learning container
Shell
50
star
7

devcontainer-features

A collection of Dev Container Features.
Shell
49
star
8

devcontainer-templates

Dev Container Templates to use Rocker based Dev Containers. Useful Templates for using R in GitHub Codespaces, etc.
Shell
23
star
9

ropensci

Dockerfile providing RStudio + Hadleyverse + rOpenSci packages
21
star
10

r-parallel

A Docker container with base R + several parallel/asynchronous packages
Shell
16
star
11

devcontainer-try-r

This repository contains some example Dev Container definitions for R and can be run on GitHub Codespaces.
Dockerfile
16
star
12

r-devel-san-clang

R devel with ASAN / UBSAN sanitizers using clang/clang++
Shell
14
star
13

devcontainer-images

R Docker images built with Dev Container Features
Makefile
12
star
14

r-devel-san

R devel with ASAN / UBSAN sanitizers
Shell
10
star
15

rstudio-daily

Daily builds of pre-release RStudio, built on daily builds of pre-release R. Live on the bleeding edge.
Shell
8
star
16

r2u

Rocker for use with r2u repository
Shell
7
star
17

rocker-paper

TeX
7
star
18

website

A website for the Rocker Project
Lua
6
star
19

ubuntu-lts

R Containers for Ubuntu LTS
Shell
6
star
20

drd

Docker R-Devel
Perl
4
star
21

drp

Docker R-Patched
Perl
2
star
22

rspm

Rocker RSPM Containers
Shell
2
star
23

bspm

Rocker BSPM Containers
Dockerfile
1
star
24

r-devel

Perl
1
star