Build the image
Clone the Copilot API repository and build the Docker image from source:http://localhost:4141/.
Run with persistent storage
Create a directory on your host to store tokens and request history, then mount it into the container:- Authentication tokens — GitHub and Copilot tokens acquired during the OAuth flow
admin.sqlite— Request history database used by the Admin UI at/admin
Run with a GitHub token
If you already have a GitHub token, pass it directly as an environment variable to skip the interactive OAuth flow:Additional environment variables
You can combine environment variables to configure authentication and access control:COPILOT_API_KEY is a legacy fallback. For new setups, configure auth.apiKeys in config.json and mount it into the container, or use the Admin API to update the configuration.Docker Compose
Use Docker Compose for a more reproducible setup:docker-compose.yml in the repository root, then run:
Add multiple accounts
The Docker image’s entrypoint runs thestart command by default. To run auth subcommands inside the container, prefix them with --auth.
Add accounts one at a time. Each run opens an interactive OAuth flow:
copilot-data directory. When the proxy runs with multiple accounts, premium-model requests use accounts in order and automatically switch when one account’s premium quota is exhausted. Free-model requests are distributed round-robin across accounts by default.
Docker image features
The includedDockerfile provides:
- Multi-stage build — builder stage installs dependencies and compiles; runner stage copies only production artifacts, keeping the final image small
- Non-root user — the container runs as a non-root user to reduce the attack surface
- Health check — Docker monitors
http://localhost:4141/every 30 seconds and marks the container unhealthy after 3 failed attempts - Pinned base image —
oven/bun:1.3.11-alpineis pinned by version for reproducible builds