|
| 1 | +# Docker Mirror Support for kdevops |
| 2 | + |
| 3 | +This document describes the Docker registry mirror feature in kdevops, which provides local caching of Docker images to speed up container-based workflows. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The Docker mirror feature provides a local Docker registry that acts as a pull-through cache for Docker Hub and other registries. This significantly speeds up container deployments and enables offline operation with cached images. |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **Local Docker Registry**: Runs a Docker registry mirror on localhost:5000 |
| 12 | +- **Pull-through Cache**: Automatically caches images as they are pulled |
| 13 | +- **Automatic Detection**: Workflows automatically detect and use the mirror when available |
| 14 | +- **NFS Server Integration**: Mirror can be shared via NFS to other systems |
| 15 | +- **Offline Operation**: Use cached images without internet connectivity |
| 16 | + |
| 17 | +## Configuration |
| 18 | + |
| 19 | +Enable Docker mirror support in menuconfig: |
| 20 | + |
| 21 | +```bash |
| 22 | +make menuconfig |
| 23 | +# Navigate to: Kernel development environment -> Mirror options |
| 24 | +# Enable: Enable Docker registry mirror support |
| 25 | +# Enable: Install Docker registry mirror |
| 26 | +``` |
| 27 | + |
| 28 | +Configuration options: |
| 29 | + |
| 30 | +- `CONFIG_ENABLE_DOCKER_MIRROR`: Enable Docker mirror support (auto-detected) |
| 31 | +- `CONFIG_USE_DOCKER_MIRROR`: Use Docker mirror if available (auto-detected) |
| 32 | +- `CONFIG_INSTALL_DOCKER_MIRROR`: Install Docker registry mirror |
| 33 | +- `CONFIG_DOCKER_MIRROR_PORT`: Registry port (default: 5000) |
| 34 | +- `CONFIG_DOCKER_MIRROR_PATH`: Storage path (default: /mirror/docker) |
| 35 | +- `CONFIG_DOCKER_MIRROR_PULL_THROUGH_CACHE`: Enable pull-through cache mode |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +### Setup the Docker Mirror |
| 40 | + |
| 41 | +```bash |
| 42 | +# Configure and install the mirror |
| 43 | +make menuconfig # Enable Docker mirror options |
| 44 | +make mirror # Sets up all mirrors with background downloads |
| 45 | + |
| 46 | +# Or setup Docker mirror only |
| 47 | +make docker-mirror # Quick setup, downloads happen in background |
| 48 | +``` |
| 49 | + |
| 50 | +The setup completes immediately and downloads happen in the background via systemd: |
| 51 | +- Initial download starts immediately upon timer activation |
| 52 | +- Daily updates at 2 AM local time |
| 53 | +- Check progress: `journalctl -u docker-mirror-update.service -f` |
| 54 | +- Check status: `systemctl status docker-mirror-update.timer` |
| 55 | + |
| 56 | +### Manual Image Operations (Optional) |
| 57 | + |
| 58 | +```bash |
| 59 | +# Force immediate image pull (blocks until complete) |
| 60 | +make docker-mirror-pull |
| 61 | + |
| 62 | +# Or use the script directly with custom images |
| 63 | +scripts/mirror-docker-images.sh [images-list-file] [--scan] [--archive] |
| 64 | +``` |
| 65 | + |
| 66 | +### Check Mirror Status |
| 67 | + |
| 68 | +```bash |
| 69 | +# Check if Docker mirror is running |
| 70 | +make docker-mirror-status |
| 71 | + |
| 72 | +# Or use the script |
| 73 | +scripts/check_docker_mirror.sh DOCKER_MIRROR_EXISTS |
| 74 | +``` |
| 75 | + |
| 76 | +## How It Works |
| 77 | + |
| 78 | +### Mirror Detection |
| 79 | + |
| 80 | +The system automatically detects if a Docker mirror is available by: |
| 81 | + |
| 82 | +1. Checking if `/mirror/docker/` directory exists |
| 83 | +2. Verifying the registry service is running on the configured port |
| 84 | +3. Testing registry accessibility via HTTP |
| 85 | + |
| 86 | +### Workflow Integration |
| 87 | + |
| 88 | +Workflows automatically use the Docker mirror based on Kconfig detection: |
| 89 | + |
| 90 | +1. Kconfig detects if `/mirror/docker/` exists and registry is running |
| 91 | +2. Sets `use_docker_mirror` variable automatically |
| 92 | +3. Workflows rewrite image URLs when mirror is enabled |
| 93 | +4. Fall back to original registries if mirror is unavailable |
| 94 | + |
| 95 | +Example from MinIO workflow: |
| 96 | + |
| 97 | +```yaml |
| 98 | +- name: Set MinIO container image with Docker mirror if enabled |
| 99 | + ansible.builtin.set_fact: |
| 100 | + minio_container_image_final: "localhost:{{ docker_mirror_port }}/{{ minio_container_image | regex_replace('^[^/]+/', '') }}" |
| 101 | + when: |
| 102 | + - use_docker_mirror | default(false) | bool |
| 103 | + |
| 104 | +- name: Start MinIO container |
| 105 | + community.docker.docker_container: |
| 106 | + name: "{{ minio_container_name }}" |
| 107 | + image: "{{ minio_container_image_final }}" |
| 108 | +``` |
| 109 | +
|
| 110 | +### Supported Images |
| 111 | +
|
| 112 | +The Docker mirror automatically caches the following images: |
| 113 | +
|
| 114 | +- **MinIO**: Object storage service |
| 115 | +- **Milvus**: Vector database for AI workloads |
| 116 | +- **vLLM**: High-performance LLM inference engine |
| 117 | + - `vllm/vllm-openai:latest` for standard GPU deployments |
| 118 | + - `openeuler/vllm-cpu:latest` for CPU inference deployments |
| 119 | + - `ghcr.io/vllm-project/production-stack/router:latest` for production stack router |
| 120 | +- **LMCache**: Advanced KV cache offloading for vLLM |
| 121 | + - `lmcache/vllm-openai:2025-05-27-v1` for stable LMCache features |
| 122 | + - `lmcache/vllm-openai:latest-nightly` for experimental cache server features |
| 123 | +- **Registry**: Docker registry itself |
| 124 | +- **etcd**: Distributed key-value store |
| 125 | + |
| 126 | +#### vLLM and LMCache Images |
| 127 | + |
| 128 | +The mirror includes support for vLLM inference deployments: |
| 129 | + |
| 130 | +- **Standard GPU deployments**: Use `vllm/vllm-openai:latest` for single-node LLM serving with GPU |
| 131 | +- **CPU inference deployments**: Use `openeuler/vllm-cpu:latest` for CPU-only inference (includes CPU optimizations) |
| 132 | +- **Production stack**: Use `ghcr.io/vllm-project/production-stack/router:latest` with the Helm-based deployment |
| 133 | +- **LMCache deployments**: Use `lmcache/vllm-openai:2025-05-27-v1` for: |
| 134 | + - KV cache offloading to reduce GPU memory usage |
| 135 | + - Disaggregated prefill for better resource utilization |
| 136 | + - KV-aware routing and prefix caching |
| 137 | +- **Experimental features**: Use `lmcache/vllm-openai:latest-nightly` for testing newest cache server capabilities |
| 138 | + |
| 139 | +These images are automatically updated daily via systemd timers to ensure you have the latest optimizations and fixes. |
| 140 | + |
| 141 | +## Scripts |
| 142 | + |
| 143 | +### docker-mirror-setup.sh |
| 144 | + |
| 145 | +Sets up the Docker registry mirror: |
| 146 | + |
| 147 | +```bash |
| 148 | +./scripts/docker-mirror-setup.sh [MIRROR_DIR] [REGISTRY_PORT] [REGISTRY_NAME] |
| 149 | +``` |
| 150 | + |
| 151 | +Features: |
| 152 | +- Creates directory structure |
| 153 | +- Configures registry with pull-through cache |
| 154 | +- Starts registry container |
| 155 | +- Optional Docker daemon configuration |
| 156 | + |
| 157 | +### mirror-docker-images.sh |
| 158 | + |
| 159 | +Pulls and caches Docker images: |
| 160 | + |
| 161 | +```bash |
| 162 | +./scripts/mirror-docker-images.sh [images-list-file] [options] |
| 163 | +
|
| 164 | +Options: |
| 165 | + --scan Scan kdevops configuration for Docker images |
| 166 | + --archive Save images to compressed tar archives |
| 167 | +``` |
| 168 | + |
| 169 | +### check_docker_mirror.sh |
| 170 | + |
| 171 | +Checks Docker mirror availability: |
| 172 | + |
| 173 | +```bash |
| 174 | +./scripts/check_docker_mirror.sh [CHECK_TYPE] |
| 175 | +
|
| 176 | +CHECK_TYPE: |
| 177 | + DOCKER_MIRROR_URL - Returns mirror URL if available |
| 178 | + DOCKER_MIRROR_EXISTS - Returns true/false for mirror existence |
| 179 | + DOCKER_MIRROR_DIR - Returns mirror directory if exists |
| 180 | + IMAGE_EXISTS [image] - Check if specific image exists in mirror |
| 181 | +``` |
| 182 | + |
| 183 | +## Architecture |
| 184 | + |
| 185 | +``` |
| 186 | +/mirror/docker/ |
| 187 | +├── registry/ # Registry data storage |
| 188 | +├── config/ # Registry configuration |
| 189 | +│ └── config.yml # Registry config with pull-through cache |
| 190 | +├── images/ # Image management |
| 191 | +│ ├── manifest.txt # List of cached images |
| 192 | +│ └── archives/ # Optional tar archives of images |
| 193 | +└── ... |
| 194 | +``` |
| 195 | +
|
| 196 | +## Benefits |
| 197 | +
|
| 198 | +1. **Faster Deployments**: Images are served from local cache |
| 199 | +2. **Bandwidth Savings**: Images downloaded once, used many times |
| 200 | +3. **Offline Operation**: Continue working without internet access |
| 201 | +4. **Consistent Environments**: All systems use same image versions |
| 202 | +5. **Integration with NFS**: Share cached images across network |
| 203 | +
|
| 204 | +## Troubleshooting |
| 205 | +
|
| 206 | +### Registry Not Starting |
| 207 | +
|
| 208 | +Check if port 5000 is available: |
| 209 | +```bash |
| 210 | +sudo netstat -tlnp | grep 5000 |
| 211 | +``` |
| 212 | + |
| 213 | +### Images Not Being Cached |
| 214 | + |
| 215 | +Verify registry is in pull-through mode: |
| 216 | +```bash |
| 217 | +docker exec kdevops-docker-mirror cat /etc/docker/registry/config.yml | grep proxy |
| 218 | +``` |
| 219 | + |
| 220 | +### Workflows Not Using Mirror |
| 221 | + |
| 222 | +Check if auto-detect is enabled: |
| 223 | +```bash |
| 224 | +grep DOCKER_MIRROR_AUTO_DETECT .config |
| 225 | +``` |
| 226 | + |
| 227 | +## Systemd Timers |
| 228 | + |
| 229 | +Docker images are automatically updated daily via systemd timers: |
| 230 | + |
| 231 | +- **Service**: `docker-mirror-update.service` - Updates Docker images |
| 232 | +- **Timer**: `docker-mirror-update.timer` - Runs daily at 2 AM |
| 233 | +- **Logs**: Stored in `/mirror/docker/logs/` with 30-day rotation |
| 234 | + |
| 235 | +Check timer status: |
| 236 | +```bash |
| 237 | +systemctl status docker-mirror-update.timer |
| 238 | +systemctl list-timers docker-mirror-update.timer |
| 239 | +``` |
| 240 | + |
| 241 | +Run manual update: |
| 242 | +```bash |
| 243 | +systemctl start docker-mirror-update.service |
| 244 | +``` |
| 245 | + |
| 246 | +## Future Enhancements |
| 247 | + |
| 248 | +- Support for multiple upstream registries |
| 249 | +- Image garbage collection policies |
| 250 | +- Web UI for registry management |
| 251 | +- Metrics and monitoring integration |
| 252 | +- Support for private registries with authentication |
0 commit comments