One-shot mirror injection for Docker builds and compose workflows.
mirrormate is a prefix-style wrapper that injects mirror sources for image pulls and build-time package installs, without modifying your repo Dockerfile or compose files. It generates temporary files, runs the real Docker/Compose command, and cleans up automatically.
Features
- Prefix wrapper:
mirrormate docker .../mirrormate docker compose .../mirrormate docker-compose ... - Mirrors are configured per tool (apt/apk/pip/npm/yarn/pnpm/go/rust), not global HTTP proxy
- Zero repo changes (temporary Dockerfile/compose only)
- Best-effort: missing config or files falls back to the original command
Install
go install github.com/samzong/mirrormate@latest
Usage
mirrormate --dry-run docker build . mirrormate docker build -t myimg . mirrormate docker buildx build --platform linux/amd64 . mirrormate docker compose up -d mirrormate docker-compose up -d mirrormate docker pull ubuntu:22.04 mirrormate docker run --rm ubuntu:22.04 echo hello
Config
Create ~/.mirrormate.yaml. Only configured sections are applied; anything missing is skipped.
registries: docker.io: m.daocloud.io/docker.io ghcr.io: m.daocloud.io/ghcr.io apt: mirror: http://mirrors.aliyun.com/debian security: http://mirrors.aliyun.com/debian-security apk: mirror: https://mirrors.aliyun.com/alpine pip: index_url: https://pypi.tuna.tsinghua.edu.cn/simple trusted_host: pypi.tuna.tsinghua.edu.cn npm: registry: https://registry.npmmirror.com yarn: registry: https://registry.npmmirror.com pnpm: registry: https://registry.npmmirror.com go: proxy: https://goproxy.cn,direct rust: cargo_registry: sparse+https://rsproxy.cn/crates.io-index/ rustup_dist_server: https://rsproxy.cn rustup_update_root: https://rsproxy.cn/rustup
Supported Commands
docker builddocker buildx builddocker compose(v2)docker-compose(v1)docker run/docker pull(best-effort image rewrite)
Notes
- If
~/.mirrormate.yamlis missing or invalid, mirrormate prints a warning and runs the original command unchanged. - Dockerfile/compose files are never modified in place.
License
MIT