Main topics
What is a Docker Container?
Design and build your Shiny App
Create a Dockerfile
Build your adhoc Docker image from Dockerfile
Deploy Shiny app to a Docker Container
Pablo Leon-Rodenas|Data and Analytics|NHSE|RPySOC24
November 22, 2024
What is a Docker Container?
Design and build your Shiny App
Create a Dockerfile
Build your adhoc Docker image from Dockerfile
Deploy Shiny app to a Docker Container
A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. https://www.docker.com/
Container images become containers at runtime and in the case of Docker containers – images become containers when they run on Docker Engine.
Available for both Linux and Windows-based applications, containerized software will always run the same, regardless of the infrastructure.
Containers isolate software from its environment and ensure that it works uniformly between development and staging.
I am using Rocker Project Docker container image. A specific Docker Container for the R Environment. This allows us to start R inside a Container
Get rocker/r-base Docker image
Run Docker image to start R inside a container
This Shiny app displays COVID 19 Confirmed, Recovered and Death cases by country for two months period. I have used renv to restore entire project after snapshot taken.
It is a simplified version of this Shiny app https://github.com/Pablo-source/Basic-Shiny-app
Pull required rocker/r-base Docker image to build your own.
Actions in the Docker.txt file
Base image on rocker/r-base
Replicate local folder structure in Dockerfile
Copy files into Dockerfile
Run R scripts in Docker when buildinfg the image
https://github.com/Pablo-source/RPYSOC_2024_Docker_Shiny/blob/ main/Docker.txt
Then build a specific image based on our Dockerfile. Putting together all components for our own Docker image.
The process of building the Docker image can take a while, we are re-creating the environment and installing all packages on top of original rocker/r-base Docker image we obtained from https://hub.docker.com/_/r-base
We use docker build command at the project folder directory level. Where our Dockerfile is saved.
Use “docker image ls” command to display docker image we just built IMAGE ID: 67f74374b225
You can modify this docker image you just built and re-build it again after several changes:
docker build -t myname/myimage .
Once the Docker image has been built, then you can use it to start in an brand new container in Docker.
docker run -d –rm -p 3838:3838 my-shinyapp-image
Finally use docker push command to share your Docker image with the community of Docker users in Docker Hub.
docker push
This is Docker Hub website to share your Docker file and apps
Browse for Docker files with apps in Docker Hub https://hub.docker.com/
Any questions?
Email: pablo.leonrodenas@nhs.net
My GitHub Repo: https://github.com/Pablo-source