Skip to main content
Docker provides a containerized environment for running Qwen models with all dependencies pre-configured. This is the easiest way to get started with production deployments.

Pre-built Docker Images

Qwen provides official Docker images on Docker Hub:
Choose the image that matches your NVIDIA driver version. Check compatibility at NVIDIA CUDA Compatibility.

Quick Start

Web Demo Deployment

1

Download the Deployment Script

2

Run the Web Demo

3

Access the Interface

Open your browser and navigate to http://localhost:8901

OpenAI API Server Deployment

1

Run the API Server

2

Test the API

CLI Demo Deployment

Manual Docker Commands

Basic Container Launch

Persistent Container

For long-running deployments:
flag
required
Enable GPU access for the container
flag
Run container in detached mode (background)
flag
Automatically restart container on failure or system reboot
mount
Mount host directory to container. Use :ro for read-only access
port mapping
Map container port to host port (host:container)

Custom Dockerfile

Build your own Docker image with specific requirements:

Build and Run Custom Image

Docker Compose

Manage multi-container deployments with Docker Compose:

Launch with Docker Compose

Container Management

Monitoring

Interactive Access

Resource Limits

Production Best Practices

  • Run containers as non-root user
  • Use read-only filesystem where possible
  • Scan images for vulnerabilities
  • Keep base images updated
  • Use secrets management for sensitive data
  • Use custom networks for isolation
  • Implement reverse proxy (Nginx/Traefik)
  • Enable TLS/HTTPS
  • Configure proper firewall rules
  • Use volumes for persistent data
  • Mount model files as read-only
  • Implement proper backup strategy
  • Use volume drivers for distributed storage
  • Use Docker Swarm or Kubernetes for orchestration
  • Implement health checks
  • Configure automatic restart policies
  • Set up load balancing
  • Monitor container metrics

Troubleshooting

Error: RuntimeError: No CUDA GPUs are availableSolutions:
  • Install nvidia-docker2:
  • Verify with: docker run --rm --gpus all nvidia/cuda:11.7.1-base-ubuntu20.04 nvidia-smi
Error: CUDA out of memorySolutions:
  • Use quantized models (Int4/Int8)
  • Increase Docker memory limit
  • Use multi-GPU deployment
  • Reduce max sequence length
Issue: Container stops right after startingDebug steps:
Error: Permission denied accessing model filesSolution: Fix file permissions:

Performance Optimization

Multi-stage Builds

Reduce image size with multi-stage builds:

Layer Caching

Optimize build times:

GPU Memory Management

Next Steps

vLLM Deployment

Scale up with high-performance vLLM

Kubernetes

Deploy on Kubernetes clusters

Production Guide

Best practices for production

Monitoring

Set up monitoring and alerting