Encapsulating Discovery at UCR

A Visual Guide to Reproducible Research with Containers

The Crisis of Confidence in Computational Science

A foundational pillar of science is reproducibility. Yet, a significant portion of computational research cannot be reliably reproduced, eroding trust and hindering progress. This is a challenge we can, and must, address.

70%
of researchers have failed to reproduce another's experiments.

(Source: Nature, 2016 Survey)

Primary Roots of Irreproducibility

The "works on my machine" syndrome, a result of environmental differences, is a major, addressable cause.

The FAIR Principles: A Guiding Framework

To combat this, the FAIR principles (Findable, Accessible, Interoperable, Reusable) provide a roadmap. Containerization is a key technology that makes computational workflows FAIR.

Findable

Container images are stored in registries with unique, citable tags.

Accessible

The entire software stack runs with a single command, anywhere.

Interoperable

OCI-standard images run across platforms, from laptops to the HPCC.

Reusable

Encapsulation ensures the environment is reliable, today and tomorrow.

The Ideal UCR Research Workflow

This workflow synthesizes the best tools: using a universal standard for definition, a familiar tool for local building, and a secure, high-performance engine for execution on the UCR HPCC.

1. Definewith Dockerfile
2. Build & TestLocally with Docker
3. Sharevia Docker Hub
4. Execute at Scaleon UCR HPCC with Apptainer

Best Practices for Smaller, Faster, Safer Images

Minimize Image Size with Multi-Stage Builds

By separating build tools from the final runtime, image size is drastically reduced, improving transfer speeds and security.

Optimize Build Speed with Layer Caching

Structure your Dockerfile from least to most frequently changing instructions to maximize cache hits and achieve near-instant rebuilds during development.

Sub-Optimal ❌

`COPY . .` before `RUN pip install`. Every code change forces a slow dependency re-installation.

Optimal ✅

`COPY requirements.txt` first, then `RUN pip install`, then `COPY . .`. Dependency layers are cached.

Practical Code Examples for UCR Researchers

Multi-Stage Dockerfile (Python)

# Stage 1: Build the environment
FROM python:3.10-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt

# Stage 2: Final minimal image
FROM python:3.10-slim
WORKDIR /app
COPY --from=builder /root/.local /root/.local
COPY . .
ENV PATH=/root/.local/bin:$PATH
CMD ["python", "./your_script.py"]

Interactive Development with Docker

# Build the Docker image from your Dockerfile
docker build -t my-research-app .

# Run container, mounting your code for live editing
# Changes on your machine are reflected instantly in the container
docker run --rm -it -v $(pwd):/app my-research-app bash

Ready to Get Started?

The UCR Research Computing team is here to help you integrate these powerful tools into your research.

Contact Support: research-computing@ucr.edu