Step 2 : Containerize your app
Note
We consider that you have followed instructions described in Step 1.2:Re-use skeleton from shiny-k8s-example
Step 2.1 : Adapting the Dockerfile to your needs
To enable deployment, the Shiny application must be encapsulated in a container using Docker.
We have already created a Dockerfile, a configuration file containing all the informations required to build the container.
For further information, you can see the full content here
Now, you just need to adapt it to the requirement of your application. We will guide you line by line through this stage.
Line 1: The base image, choose versions that suits you
1# Build image from the base image, previously configured for you
2# Full list of images can be found at
3# https://hub.pages.pasteur.fr/shiny-k8s/user_guide/configure_image.html#image-list
4FROM registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.9-slim-bullseye--1.5.22.1017
1# Build image from the base image, previously configured for you
2# Full list of images can be found at
3# https://hub.pages.pasteur.fr/shiny-k8s/user_guide/configure_image.html#image-list
4FROM registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.3.1--1.5.22.1017
The FROM ... indicate which base image should be used, the image contains:
an OS with python or R, depends of your shiny app
python’s or R “shiny” package
the shiny-server
We provide various version of R and Python for your needs, here is a list (as of Aug 2026).
Language |
Base os |
R/Python |
shiny-server |
Built image |
|---|---|---|---|---|
python |
bookworm |
3.10 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.10-slim |
python |
bookworm |
3.11 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.11-slim |
python |
bookworm |
3.12 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.12-slim |
python |
bookworm |
3.13 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.13-slim |
python |
bookworm |
3.14 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.14-slim |
python |
bookworm |
3.14 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:latest |
python |
bullseye |
3.10 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.10-slim-bullseye |
python |
bullseye |
3.11 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.11-slim-bullseye |
python |
bullseye |
3.12 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.12-slim-bullseye |
python |
bullseye |
3.13 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.13-slim-bullseye |
python |
bullseye |
3.14 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.14-slim-bullseye |
python |
trixie |
3.10 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.10-slim-trixie |
python |
trixie |
3.11 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.11-slim-trixie |
python |
trixie |
3.12 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.12-slim-trixie |
python |
trixie |
3.13 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.13-slim-trixie |
python |
trixie |
3.14 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.14-slim-trixie |
r |
focal |
4.1.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.1.3-focal |
r |
focal |
4.2.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.2.3-focal |
r |
focal |
4.3.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.3.3-focal |
r |
focal |
4.4.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.4.3-focal |
r |
focal |
4.5.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.5.3-focal |
r |
focal |
4.6.0 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.6.0-focal |
r |
jammy |
4.1.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.1.3 |
r |
jammy |
4.2.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.2.3 |
r |
jammy |
4.3.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.3.3 |
r |
jammy |
4.4.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.4.3 |
r |
jammy |
4.5.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.5.3 |
r |
jammy |
4.6.0 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.6.0 |
r |
jammy |
4.6.0 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:latest |
r |
noble |
4.3.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.3.3-noble |
r |
noble |
4.4.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.4.3-noble |
r |
noble |
4.5.3 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.5.3-noble |
r |
noble |
4.6.0 |
latest |
registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.6.0-noble |
If a version of R, Python, shiny-server, Debian or Ubuntu is missing please read FAQ here.
For more details about base images, please see the dedicated pages for python and R.
Lines 10-13: Add the required system dependencies (Optionnal)
9# Install additional dependencies, uncomment the block if you have one, and edit/duplicate line 12
10# RUN apt-get update \
11# && apt-get install -y \
12# your-system-dependency \
13# && rm -rf /var/lib/apt/lists/*
9# Install additional dependencies, uncomment the block if you have one, and edit/duplicate line 12
10RUN apt-get update \
11 && apt-get install -y \
12 your-system-dependency_1 \
13 your-system-dependency_2 \
14 && rm -rf /var/lib/apt/lists/*
Some of your package dependencies require system dependencies (such as graphviz-dev for pygraphviz) that must be included in the Docker image.
Tip
If you have no additional system dependencies you can keep this block commented.
Don’t forget to come back and add system dependencies, if during the development or testings stages of your application, you find that you need them.
Line 25: Copy your app into the docker image
24# Copy you shiny app
25COPY ./my_project /srv/shiny-server
At that moment you copy you shiny app into the Docker image.
Here, you need to adapt the line according to your directory name
Let us consider that you want to store the sources in src or my_beautifull_shiny_app folder.
You have change the COPY instruction as follows :
...
# Copy you shiny app
-COPY ./my_project /srv/shiny-server
+COPY ./src /srv/shiny-server
...
...
# Copy you shiny app
-COPY ./my_project /srv/shiny-server
+COPY ./my_beautifull_shiny_app /srv/shiny-server
...
Note that the directory named my_project contains a shiny example
Step 2.2 : List your packages
According to your needs and the language used, you must list all additional packages in the dedicated file.
Tip
Don’t forget to complete the packages file as needed during the development or testings stages of your application.
Python: requirements.txt
This file is the default file for dependencies in python. You can specify package, with or without a specific version, install from a git. The syntax to respect is the following :
sphinx=~7.0.1
sphinx_rtd_theme
git+https://gitlab.pasteur.fr/user/some-project.git@v1.3
By default, in the gitlab project shiny-k8s-example, the python packages mentionned in the requirements.txt file are
shiny and htmltools.
shiny
htmltools
You are free to modify this list. shiny package is already installed in the previous base image, created at shiny-k8s level.
R: my_packages_to_install.csv
In this file you list in csv file the packages (with ; as separator).
For each file, how it can be found is specified in the second column.
If can be from cran, from bioconductor, or even a github package.
You can also specify the wanted version by add @VersionNumber as ggplot2@3.5.2
Package_name;Comments
shinythemes;cran package
ggplot2@3.5.2;cran package
limma;bioconductor package
tidyverse/tibble; github package
The use of this file in the container is explained here
Additionnal informations : Full description of Dockerfile
For further information, here, you can see the full content of the Dockerfile:
1# Build image from the base image, previously configured for you
2# Full list of images can be found at
3# https://hub.pages.pasteur.fr/shiny-k8s/user_guide/configure_image.html#image-list
4FROM registry-gitlab.pasteur.fr/hub/shiny-k8s/python:3.9-slim-bullseye--1.5.22.1017
5
6# Add workdir information
7WORKDIR /srv/shiny-server/
8
9# Install additional dependencies, uncomment the block if you have one, and edit/duplicate line 12
10# RUN apt-get update \
11# && apt-get install -y \
12# your-system-dependency \
13# && rm -rf /var/lib/apt/lists/*
14
15# Copy your dependencies, destination filename must be "packages_to_install.csv"
16COPY ./requirements.txt /opt/scripts/requirements.txt
17
18# Install Python packages
19RUN pip install -r /opt/scripts/requirements.txt
20
21# grant shiny to created bookmark state directory in this directory
22RUN chown shiny:shiny /var/lib/shiny-server
23
24# Copy you shiny app
25COPY ./my_project /srv/shiny-server
26
27# grant shiny to use www folder
28RUN chown shiny:shiny /srv/shiny-server/www
1# Build image from the base image, previously configured for you
2# Full list of images can be found at
3# https://hub.pages.pasteur.fr/shiny-k8s/user_guide/configure_image.html#image-list
4FROM registry-gitlab.pasteur.fr/hub/shiny-k8s/r:4.3.1--1.5.22.1017
5
6# Add workdir information
7WORKDIR /srv/shiny-server/
8
9# Install additional dependencies, uncomment the block if you have one, and edit/duplicate line 12
10# RUN apt-get update \
11# && apt-get install -y \
12# your-system-dependency \
13# && rm -rf /var/lib/apt/lists/*
14
15# Copy your dependencies, destination filename must be "packages_to_install.csv"
16COPY ./my_packages_to_install.csv /opt/scripts/packages_to_install.csv
17
18# Install R packages
19RUN Rscript /opt/scripts/install_r_packages.R
20
21# grant shiny to created bookmark state directory in this directory
22RUN chown shiny:shiny /var/lib/shiny-server
23
24# Copy you shiny app
25COPY ./my_project /srv/shiny-server
26
27# grant shiny to use www folder
28RUN chown shiny:shiny /srv/shiny-server/www
please find here the meaning of the lines that you did not have to modify previously.
Line 7: Working Directory
6# Add workdir information
7WORKDIR /srv/shiny-server/
We set the current working directory to /srv/shiny-server/ .
Lines 16-19: The package dependencies
15# Copy your dependencies, destination filename must be "packages_to_install.csv"
16COPY ./requirements.txt /opt/scripts/requirements.txt
17
18# Install Python packages
19RUN pip install -r /opt/scripts/requirements.txt
15# Copy your dependencies, destination filename must be "packages_to_install.csv"
16COPY ./my_packages_to_install.csv /opt/scripts/packages_to_install.csv
17
18# Install R packages
19RUN Rscript /opt/scripts/install_r_packages.R
The package dependencies are copied into the images line 16, and installed line 19. The format of the file listing the dependencies depends on the language you use:
Python : requirement.txt file
R : my_packages_to_install.csv file
More details about the content of these files available here
Line 22: Grant shiny to create bookmark state
21# grant shiny to created bookmark state directory in this directory
22RUN chown shiny:shiny /var/lib/shiny-server
In order to run your application, the user shiny must be allow to write file in
/var/lib/shiny-server directory .
Line 28: Grant shiny to write output data
27# grant shiny to use www folder
28RUN chown shiny:shiny /srv/shiny-server/www
When your application produce files, they are written in www directory, thus this
directory must be own by user shiny , the user who will run the app.