-
Notifications
You must be signed in to change notification settings - Fork 84
Docker Deployment
This guide explains how to deploy CPA-Manager Usage Service with Docker, and how to use it either as a full panel entry point or as an external Usage Service for the CPA built-in panel.
The CPA-Manager Docker image includes:
- CPA-Manager Usage Service
- Embedded
management.htmlpanel - SQLite-backed usage persistence
- Proxy support for CPA Management API
Note: The Docker image does not include CLIProxyAPI itself.
You still need to deploy and run CLIProxyAPI separately.
Docker deployment is recommended if you want:
- A quick way to start CPA-Manager Usage Service
- A stable background service
- Persistent SQLite data through Docker volumes
- A single entry point for the management panel
- Less manual work compared with native binary + systemd deployment
If your server has very limited disk space, see:
CPA-Manager Docker deployment can be used in two main modes.
| Mode | Entry URL | Description | Best For |
|---|---|---|---|
| Full Docker Mode | http://<host>:18317/management.html |
Open the embedded panel from Usage Service | New deployments, one entry point, fewer CORS issues |
| CPA Panel Mode | http://<cpa-host>:8317/management.html |
Keep using CPA's built-in panel and configure an external Usage Service | Existing CPA deployments |
For new users, Full Docker Mode is recommended.
You need to run CLIProxyAPI separately.
Typical CPA URL:
http://<cpa-host>:8317
Typical CPA panel URL:
http://<cpa-host>:8317/management.html
You need the CPA Management Key.
CPA-Manager Usage Service uses it to:
- Verify the CPA connection
- Proxy CPA Management API
- Enable usage publishing
- Consume the CPA usage queue
- Authenticate later panel logins
Recommended:
CLIProxyAPI >= v7.1.0
CPA v7.0.7+ supports Redis Pub/Sub subscription for live usage events, and CPA v6.10.8+ supports the HTTP usage queue, which is easier to deploy and reverse proxy than RESP polling.
This is the recommended mode.
Start the container:
docker run -d \
--name cpa-manager \
--restart unless-stopped \
-p 18317:18317 \
-v cpa-manager-data:/data \
seakee/cpa-manager:latestOpen:
http://<host>:18317/management.html
On first setup, enter:
CPA URL
Management Key
Request Monitoring
Collection Mode
Poll Interval
Example:
CPA URL: http://192.168.1.10:8317
Management Key: <your-management-key>
Request Monitoring: enabled
Collection Mode: auto
Poll Interval: 500
After setup:
- CPA URL and Management Key are saved in Usage Service SQLite
- Request monitoring data is stored in
/data/usage.sqlite - Later visits only require the Management Key
- CPA management APIs are proxied through Usage Service
- Usage statistics and request monitoring APIs read from Usage Service SQLite
Create docker-compose.yml:
services:
cpa-manager:
image: seakee/cpa-manager:latest
container_name: cpa-manager
restart: unless-stopped
ports:
- "18317:18317"
environment:
HTTP_ADDR: "0.0.0.0:18317"
USAGE_DATA_DIR: "/data"
USAGE_DB_PATH: "/data/usage.sqlite"
USAGE_COLLECTOR_MODE: "auto"
USAGE_BATCH_SIZE: "100"
USAGE_POLL_INTERVAL_MS: "500"
USAGE_QUERY_LIMIT: "50000"
USAGE_CORS_ORIGINS: "*"
volumes:
- cpa-manager-data:/data
healthcheck:
test: ["CMD", "wget", "-qO-", "http://127.0.0.1:18317/health"]
interval: 10s
timeout: 3s
retries: 3
volumes:
cpa-manager-data:Start:
docker compose up -dView logs:
docker logs -f cpa-managerCheck container status:
docker psHealth check:
curl http://127.0.0.1:18317/healthIf CPA runs directly on the Linux host and CPA-Manager runs inside Docker, the container cannot use 127.0.0.1 to reach the host CPA.
Use host.docker.internal:
docker run -d \
--name cpa-manager \
--restart unless-stopped \
--add-host=host.docker.internal:host-gateway \
-p 18317:18317 \
-v cpa-manager-data:/data \
seakee/cpa-manager:latestDuring setup, use:
http://host.docker.internal:8317
Do not use:
http://127.0.0.1:8317
Inside the container, 127.0.0.1 means the container itself, not the host.
If you want to keep using CPA's built-in /management.html, you can run Docker only as the external Usage Service.
Steps:
- Start CPA.
- Start CPA-Manager Usage Service:
docker run -d \
--name cpa-manager \
--restart unless-stopped \
-p 18317:18317 \
-v cpa-manager-data:/data \
seakee/cpa-manager:latest- Open CPA's built-in panel:
http://<cpa-host>:8317/management.html
- Go to:
Configuration -> CPA-Manager Configuration
- Enable CPA-Manager Usage Service and enter:
http://<usage-service-host>:18317
- Save the configuration.
After saving:
- Normal CPA management APIs still go to CPA
- Usage statistics and request monitoring APIs go to Usage Service
- The panel sends the current CPA URL and Management Key to Usage Service
- Usage Service consumes CPA usage queue based on the saved configuration
If the service is reachable at:
http://1.2.3.4:18317
Then fill:
http://1.2.3.4:18317
If Usage Service is behind Nginx or Caddy:
https://cpam.example.com
Then fill:
https://cpam.example.com
If you open the remote CPA panel from your local browser:
http://127.0.0.1:18317
means your local computer, not the server.
Use the server IP, domain, or reverse proxy URL instead.
In Docker deployment, the default data directory is:
/data
The default SQLite database is:
/data/usage.sqlite
Always mount /data:
-v cpa-manager-data:/dataOtherwise, usage data will be lost after the container is recreated.
Pull the latest image:
docker pull seakee/cpa-manager:latestStop and remove the old container:
docker stop cpa-manager
docker rm cpa-managerStart again:
docker run -d \
--name cpa-manager \
--restart unless-stopped \
-p 18317:18317 \
-v cpa-manager-data:/data \
seakee/cpa-manager:latestWith Docker Compose:
docker compose pull
docker compose up -dBack up the data volume before upgrading when possible.
For Docker named volume:
docker run --rm \
-v cpa-manager-data:/data \
-v "$PWD":/backup \
alpine \
tar czf /backup/cpa-manager-data-backup.tar.gz -C /data .Restore:
docker run --rm \
-v cpa-manager-data:/data \
-v "$PWD":/backup \
alpine \
sh -c "cd /data && tar xzf /backup/cpa-manager-data-backup.tar.gz"| Variable | Default | Description |
|---|---|---|
HTTP_ADDR |
0.0.0.0:18317 |
Usage Service listen address |
USAGE_DATA_DIR |
/data |
Data directory |
USAGE_DB_PATH |
/data/usage.sqlite |
SQLite database path |
CPA_UPSTREAM_URL |
empty | Optional preconfigured CPA URL |
CPA_MANAGEMENT_KEY |
empty | Optional preconfigured Management Key |
CPA_MANAGEMENT_KEY_FILE |
/run/secrets/cpa_management_key |
Optional Management Key file |
USAGE_COLLECTOR_MODE |
auto |
Collection mode: auto, subscribe, http, or resp; auto tries subscribe, then HTTP, then RESP |
USAGE_BATCH_SIZE |
100 |
Maximum queue records per batch |
USAGE_POLL_INTERVAL_MS |
500 |
Idle polling interval |
USAGE_QUERY_LIMIT |
50000 |
Maximum recent usage records returned |
USAGE_CORS_ORIGINS |
* |
Allowed browser origins for CPA Panel Mode |
Most users do not need to set CPA_UPSTREAM_URL or CPA_MANAGEMENT_KEY manually. The web setup flow is recommended.
Usage Service has already been configured.
Enter the saved Management Key to log in.
To reset the setup, back up the data first, then remove or reset the SQLite database under /data.
On Linux, add:
--add-host=host.docker.internal:host-gatewayThen use:
http://host.docker.internal:8317
as the CPA URL.
Check:
- CPA Management API is enabled
- Management Key is correct
- CPA usage publishing is enabled
- Usage Service
/statusis healthy - Only one Usage Service consumes the same CPA queue
- CPA version is not too old
-
USAGE_POLL_INTERVAL_MSis within the CPA usage queue retention window
Check whether /data is mounted.
Correct:
-v cpa-manager-data:/dataWrong:
docker run seakee/cpa-manager:latestWithout a persistent volume, SQLite data is lost when the container is removed.
For private deployments, the default is usually fine:
USAGE_CORS_ORIGINS=*
For public deployments, restrict it to the CPA panel origin:
USAGE_CORS_ORIGINS=https://cpa.example.com