Skip to content

Docker & Apptainer Containers

Kubernetes executes container images based on the Open Container Initiative (OCI) standard. You can build your images using Docker, Podman, or Apptainer / Singularity.

Example: Scientific Python & CUDA Dockerfile

Section titled “Example: Scientific Python & CUDA Dockerfile”

Here is a recommended Dockerfile template with non-root user permissions and PyTorch GPU support:

# Use official NVIDIA PyTorch base image
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
# Install system utilities and scientific libraries
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
curl \
htop \
rsync \
libgl1-mesa-glx \
&& rm -rf /var/lib/apt/lists/*
# Install Python requirements
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
# Create non-root research user (UID 1000)
RUN useradd -m -u 1000 scientist
USER scientist
WORKDIR /home/scientist
# Copy project source code
COPY --chown=scientist:scientist . /home/scientist/app
CMD ["python", "app/train.py"]

Terminal window
# Build the container image locally
docker build -t registry.berkelium.lbl.gov/sci-als/synchrotron-model:v1 .
# Log in and push
docker push registry.berkelium.lbl.gov/sci-als/synchrotron-model:v1