This repository provides a Docker-based RStudio Server environment configured to connect to a DB2 database. It is designed to simulate research environments that use this configuration, such as the SAIL Databank, offering a reproducible, containerised analysis environment.
rstudio-db2-lab/
├── docker/
│ └── rstudio/
│ ├── Dockerfile # Builds the RStudio Server image with DB2
│ └── v11.5.8_linuxx64_odbc_cli.tar.gz # IBM DB2 ODBC/CLI driver (downloaded separately)
├── workspace/ # Mounted workspace inside RStudio container
├── r_packages/ # Persisted R packages installed in container
├── docker-compose.yml # Docker Compose to orchestrate DB2 + RStudio
└── README.md # Documentation and installation guide
- Docker Desktop (≥ 20.10, includes Docker Compose v2)
- IBM Data Server Driver for ODBC and CLI (v11.5.8 or compatible)
- Modern web browser (e.g., Chrome, Firefox) to access RStudio Server
- (Optional) VS Code or any terminal/command prompt for running Docker Compose commands.
-
Visit IBM Fix Central
Go to IBM Fix Central. -
Select the Appropriate Version
- Product selector: Information Management
- Product: IBM Data Server Client Packages
- Installed version: 11.5.*
- Platform: Linux 64-bit, x86_64
-
Proceed to Downloads
- Click Continue from the "Identify fixes" window (ensure Browse for fixes is selected).
- Locate the fix pack:
DSClients-linuxx64-odbc_cli-11.5.8.0-FP000– IBM Data Server Driver for ODBC and CLI (Linux/x86-64) V11.5.8 Fix Pack 0
-
Download the Driver
- Sign in to your IBM account if prompted.
- Download the file:
v11.5.8_linuxx64_odbc_cli.tar.gz
-
Place the Driver in the Project
- Move the downloaded
v11.5.8_linuxx64_odbc_cli.tar.gzfile into thedocker/rstudio/folder.
- Move the downloaded
-
Docker Integration
- The
Dockerfileis configured to automatically copy and install the driver when building the RStudio image.
- The
Ensure Docker Desktop is running. From the repository root:
docker-compose builddocker-compose up -d- DB2 will start and listen on port
50000. - RStudio Server will start and be accessible at http://localhost:8787
Note:
- DB2 may take a couple of minutes to finish starting up.
- To monitor progress, run:
docker logs -f db2
- Wait until you see the message:
SQL1063N DB2START processing was successful. ... (*) All databases are now active. (*) Setup has completed.
- This confirms DB2 is fully started.
- Press Ctrl + C to exit the live logs once you see this message.
- Open http://localhost:8787 in your browser.
- Username:
rstudio - Password: set in
docker-compose.yml(defaultPassw0rd)
library(DBI)
library(odbc)
con <- dbConnect(
odbc(),
dsn = "PR_SAIL",
uid = "db2inst1",
pwd = "Passw0rd"
)PR_SAILis the DSN configured in the Dockerfile for the DB2 container.- All scripts and projects should reference this DSN.
-
The
workspace/folder on the host is mounted to/home/rstudioin the container. Any files saved in RStudio will persist on the host. -
The
r_packages/folder on the host is mounted to/usr/local/lib/R/site-libraryin the container. Installed R packages will persist across container rebuilds.
- The
db2dataDocker volume stores the DB2 database files. - Your test or synthetic datasets will persist across container restarts.
To stop the running containers:
docker-compose down- This shuts down DB2 and RStudio but preserves the named volumes (
db2data,workspace), so your data and installed R packages are kept.
docker-compose down -vThis will remove containers and all named volumes (db2data, workspace, r_packages), so backup any persistent work first.