Skip to main content
Mini-SGLang provides official Docker support for easy deployment in containerized environments. This guide covers building images, running containers, and best practices for production deployments.

Prerequisites

1

Install Docker

Follow the official Docker installation guide for your platform.
2

Install NVIDIA Container Toolkit

Required for GPU access in containers:
Verify installation:

Building the Docker Image

1

Clone the repository

2

Build the image

Build with default settings:
Or customize build arguments:
3

Verify the build

Check that the image was created:
Expected output:

Running the Container

Basic Server Deployment

Launch an API server with GPU access:
The --host 0.0.0.0 flag is required for the server to be accessible outside the container.

Interactive Shell Mode

Run in interactive shell mode:

Custom Port Mapping

Map to a different host port:
Access at http://localhost:8000

Using Volume Mounts

Persistent Cache Directories

Use Docker volumes to cache downloaded models and compiled kernels:
Using volume mounts significantly speeds up subsequent container starts by avoiding re-downloading models and re-compiling kernels.

Using Host Directories

Alternatively, mount specific host directories:

Multi-GPU Deployment

All Available GPUs

Specific GPUs

Select specific GPU devices:

Production Deployment

Docker Compose

Create a docker-compose.yml:
Launch with:

Health Checks

Add a health check to the Dockerfile or docker-compose.yml:

Resource Limits

Set memory and CPU limits:

Environment Variables

Pass environment variables to configure the container:

Available Environment Variables

string
Comma-separated GPU indices to use
string
HuggingFace authentication token for gated models
boolean
Set to 1 to disable overlap scheduling

Troubleshooting

Verify NVIDIA Container Toolkit is installed:
If this fails, reinstall the NVIDIA Container Toolkit.
The container runs as a non-root user (UID 1001). Ensure mounted volumes have correct permissions:
Increase Docker’s memory limit:
  • Check network connectivity
  • Try using --model-source modelscope
  • For gated models, provide HF_TOKEN environment variable

Windows (WSL2) Deployment

For Windows users with WSL2:
1

Install WSL2 and Docker Desktop

2

Build and run in WSL2

Open WSL2 terminal and follow the standard Linux instructions:
3

Access from Windows

The server will be accessible at http://localhost:1919 from Windows browsers and applications.
For production deployments with load balancing and orchestration, consider using Kubernetes with NVIDIA GPU Operator.