Docker Registry Mirror for Faster Pulls is a common requirement for VPS administrators. This guide provides practical instructions that you can follow on Ubuntu 22.04/24.04 or Debian 12, though most steps apply to other distributions as well.
Prerequisites
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- Docker Compose v2 installed
- A registered domain name (for public-facing services)
- Docker Engine 24.0+ installed
- Basic familiarity with the Linux command line
Creating the Docker Compose File
After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.
# docker-compose.yml
version: '3.8'
services:
app:
image: registry:latest
restart: unless-stopped
ports:
- "8080:8080"
volumes:
- app_data:/data
environment:
- NODE_ENV=production
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
app_data:
This configuration provides a good balance between performance and resource usage. For high-traffic scenarios, you may need to increase the limits further.
Building the Container Image
Performance benchmarks show that properly tuned registry can handle significantly more concurrent connections than the default configuration. The key improvements come from adjusting worker processes and connection pooling.
# Multi-stage Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
EXPOSE 3000
CMD ["node", "dist/index.js"]
Make sure to restart the service after applying these changes. Some settings require a full restart rather than a reload to take effect.
Configuring Volumes and Networks
The mirror component plays a crucial role in the overall architecture. Understanding how it interacts with registry will help you make better configuration decisions.
# Container management commands
docker compose up -d
docker compose logs -f app
docker compose exec app sh
docker system prune -af --volumes # Caution: removes unused data
Each line in the configuration serves a specific purpose. The comments explain the reasoning behind each setting, making it easier to customize for your specific use case.
Important Notes
Security should be a primary consideration when configuring registry. Always use strong passwords, keep software updated, and restrict network access to only the necessary ports and IP addresses.
- Document all configuration changes
- Use version control for configuration files
- Maintain runbooks for common operations
- Set up monitoring before going to production
Summary
You've successfully configured registry on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.