Skip to content

JamesAFarrell/rstudio-db2-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RStudio + DB2 Research Environment

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.

Repository Structure

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 

Requirements

  • 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.

IBM Data Server Driver for ODBC and CLI

Steps to Download and Install the Driver

  1. Visit IBM Fix Central
    Go to IBM Fix Central.

  2. Select the Appropriate Version

    • Product selector: Information Management
    • Product: IBM Data Server Client Packages
    • Installed version: 11.5.*
    • Platform: Linux 64-bit, x86_64
  3. 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
  4. Download the Driver

    • Sign in to your IBM account if prompted.
    • Download the file: v11.5.8_linuxx64_odbc_cli.tar.gz
  5. Place the Driver in the Project

    • Move the downloaded v11.5.8_linuxx64_odbc_cli.tar.gz file into the docker/rstudio/ folder.
  6. Docker Integration

    • The Dockerfile is configured to automatically copy and install the driver when building the RStudio image.

Getting Started

1. Build the Docker Image

Ensure Docker Desktop is running. From the repository root:

docker-compose build

2. Start the Containers

docker-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.

3. Log In to RStudio

  • Open http://localhost:8787 in your browser.
  • Username: rstudio
  • Password: set in docker-compose.yml (default Passw0rd)

4. Connect to DB2 from R

library(DBI)
library(odbc)
con <- dbConnect(
  odbc(),
  dsn = "PR_SAIL",
  uid = "db2inst1",
  pwd = "Passw0rd"
)
  • PR_SAIL is the DSN configured in the Dockerfile for the DB2 container.
  • All scripts and projects should reference this DSN.

Persisting RStudio Workspace and Packages

  • The workspace/ folder on the host is mounted to /home/rstudio in 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-library in the container. Installed R packages will persist across container rebuilds.

DB2 Data Persistence

  • The db2data Docker volume stores the DB2 database files.
  • Your test or synthetic datasets will persist across container restarts.

Stopping the Environment

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.

Cleaning Up

docker-compose down -v

This will remove containers and all named volumes (db2data, workspace, r_packages), so backup any persistent work first.

About

Containerised RStudio Server with IBM DB2, replicating research environments for reproducible analysis.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors