Docker setup for JupyterLab with full NVIDIA GPU acceleration support. Ideal for machine learning, deep learning, and scientific computing workflows. Pre-configured with CUDA libraries and Python data science stack.
- CUDA 12.2 base image for full GPU acceleration
- Persistent storage for notebooks and datasets
- Secure authentication with password protection
- Resource isolation for GPU devices
- Pre-installed common Python ML packages
- Customizable environment via Dockerfile
- Docker Compose for single-command management
- Docker Engine 20.10+
- NVIDIA Container Toolkit (Install Guide)
- NVIDIA Drivers 525.60+ (Driver Download)
- Docker Compose 2.0+
- Minimum 10GB free disk space
Create password file (replace your_secure_password):
echo "JUPYTER_PASSWORD=your_secure_password" > .envdocker compose build --no-cacheNote: --no-cache ensures fresh dependencies install. Remove for faster rebuilds when not changing packages.
docker compose up -dOpen in browser:
http://localhost:8888
🔑 Password: your_secure_password (from .env file)
| File | Purpose | Customization |
|---|---|---|
docker-compose.yml |
Container definition | Port mapping, volume locations, GPU limits |
requirements.txt |
Python packages | Add/remove Python dependencies |
Dockerfile |
Image build recipe | System packages, environment variables |
.env |
Secrets | Jupyter password |
Change Jupyter port (edit docker-compose.yml):
ports:
- "8999:8888" # Host:Container portAdd Python packages (edit requirements.txt):
torch==2.1.0
transformers==4.35
xgboost==2.0.0
Limit GPU access (edit docker-compose.yml):
deploy:
resources:
reservations:
devices:
- driver: nvidia
count: 1 # Use only 1 GPU
capabilities: [gpu]| Command | Action |
|---|---|
docker compose logs -f |
View real-time logs |
docker compose exec jupyter bash |
Enter container shell |
docker compose restart |
Restart service |
docker compose down |
Stop container |
docker compose pull |
Update base images |
GPU not detected? Verify:
nvidia-smishows available GPUs on host- NVIDIA Container Toolkit is properly installed
- Docker has GPU access:
docker run --rm --gpus all nvidia/cuda:12.2.0-base nvidia-smiPort conflict? Change host port mapping in docker-compose.yml:
ports:
- "NEW_PORT:8888" # e.g., 9999:8888.
├── Dockerfile # Image build instructions
├── docker-compose.yml # Container configuration
├── requirements.txt # Python dependencies
├── workspace/ # Persistent notebooks (auto-created)
└── .env # Environment variables
