> ## Documentation Index
> Fetch the complete documentation index at: https://runcrate.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Run Docker Containers on GPU Instances

> Deploy a devbox instance with Docker, run GPU-accelerated containers with NVIDIA Container Toolkit.

export const RuncrateStyles = () => {
  if (typeof document !== 'undefined' && !document.getElementById('runcrate-overrides')) {
    const s = document.createElement('style');
    s.id = 'runcrate-overrides';
    s.textContent = `
      /* Match Runcrate's rounding scale (--radius: 0.75rem) */
      .rounded-sm { border-radius: 0.5rem !important; }   /* 8px */
      .rounded-md { border-radius: 0.625rem !important; } /* 10px */
      .rounded-lg { border-radius: 0.75rem !important; }  /* 12px */
      .rounded-l-sm { border-top-left-radius: 0.5rem !important; border-bottom-left-radius: 0.5rem !important; }
      .rounded-r-sm { border-top-right-radius: 0.5rem !important; border-bottom-right-radius: 0.5rem !important; }
      .rounded-l-md { border-top-left-radius: 0.625rem !important; border-bottom-left-radius: 0.625rem !important; }
      .rounded-r-md { border-top-right-radius: 0.625rem !important; border-bottom-right-radius: 0.625rem !important; }
      .rounded-l-lg { border-top-left-radius: 0.75rem !important; border-bottom-left-radius: 0.75rem !important; }
      .rounded-r-lg { border-top-right-radius: 0.75rem !important; border-bottom-right-radius: 0.75rem !important; }

      /* Cards: never pure white in light mode */
      .card { background-color: #fcfcfc !important; border-radius: 0.75rem !important; }
      html.dark .card { background-color: #141414 !important; }

      /* Docs hero box */
      .rc-hero { background-color: #fcfcfc; border: 1px solid #e0e0e0; }
      html.dark .rc-hero { background-color: #141414; border-color: #242424; }
      html.dark .rc-hero h1 { color: #f5f5f5; }

      /* Runcrate scrollbar — thin, transparent track, hide-until-hover thumb */
      ::-webkit-scrollbar { width: 6px; height: 6px; background-color: transparent; }
      ::-webkit-scrollbar-track { background-color: transparent; }
      ::-webkit-scrollbar-thumb { background-color: rgba(155, 155, 155, 0.5); border-radius: 10px; transition: opacity 0.3s ease; opacity: 0; }
      ::-webkit-scrollbar-thumb:hover { background-color: rgba(155, 155, 155, 0.7); }
      *:hover::-webkit-scrollbar-thumb,
      *:focus::-webkit-scrollbar-thumb,
      *:active::-webkit-scrollbar-thumb { opacity: 1; }
      * { scrollbar-width: thin; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; }
    `;
    document.head.appendChild(s);
  }
  return null;
};

<RuncrateStyles />

Run GPU-accelerated Docker containers on a Runcrate instance. The `ubuntu-devbox` template includes Docker and the NVIDIA Container Toolkit — pull any image and pass through the GPU with `--gpus all`.

## 1. Deploy a devbox

```bash theme={"theme":"github-dark"}
runcrate instances create --name docker-gpu --gpu RTX4090 --template ubuntu-devbox
runcrate instances status docker-gpu
```

## 2. Verify Docker and GPU access

```bash theme={"theme":"github-dark"}
runcrate ssh docker-gpu -- "docker --version"
runcrate ssh docker-gpu -- "docker run --rm --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi"
```

## 3. Run a PyTorch container

```bash theme={"theme":"github-dark"}
runcrate ssh docker-gpu -- "docker run --rm --gpus all \
  -v /workspace:/workspace \
  pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime \
  python -c 'import torch; print(f\"CUDA: {torch.cuda.is_available()}, GPU: {torch.cuda.get_device_name(0)}\")'"
```

## 4. Run vLLM in a container

```bash theme={"theme":"github-dark"}
runcrate ssh docker-gpu -- "docker run -d --gpus all \
  --name vllm-server \
  -p 8000:8000 \
  vllm/vllm-openai:latest \
  --model meta-llama/Llama-3.1-8B-Instruct \
  --max-model-len 8192 --host 0.0.0.0"
```

Test it:

```bash theme={"theme":"github-dark"}
runcrate instances info docker-gpu

curl http://<INSTANCE_IP>:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meta-llama/Llama-3.1-8B-Instruct",
    "messages": [{"role": "user", "content": "Hello from Docker."}],
    "max_tokens": 128
  }'
```

## 5. Build and run your own image

```bash theme={"theme":"github-dark"}
runcrate cp ./Dockerfile docker-gpu:/workspace/Dockerfile
runcrate cp ./app/ docker-gpu:/workspace/app/

runcrate ssh docker-gpu -- "cd /workspace && docker build -t my-gpu-app ."
runcrate ssh docker-gpu -- "docker run --rm --gpus all my-gpu-app"
```

## 6. Manage containers

```bash theme={"theme":"github-dark"}
runcrate ssh docker-gpu -- "docker ps"
runcrate ssh docker-gpu -- "docker logs vllm-server --tail 50"
runcrate ssh docker-gpu -- "docker stop vllm-server"
```

## Tips

* Always use `--gpus all` to pass GPUs into the container.
* The `ubuntu-devbox` template has Docker and `nvidia-container-toolkit` pre-installed.
* For multi-GPU instances, all GPUs are available inside the container with `--gpus all`.
* Docker images are not persisted across instance restarts. Attach a volume or use a registry.

## Cleanup

```bash theme={"theme":"github-dark"}
runcrate instances delete docker-gpu
```
