influx setup: Initialize InfluxDB 2.x in CI
influx setup runs the one-time onboarding for a fresh InfluxDB 2.x server, creating the initial org, admin user, bucket, and operator token.
A new InfluxDB 2.x instance is unconfigured until setup runs. In CI you do this non-interactively with --force so the bucket and token exist before tests write.
What it does
influx setup performs first-run initialization: it creates the initial organization, an admin username and password, an initial bucket, and an operator API token, then writes a local config profile so later influx commands are authenticated. It can run only once per server unless the instance is reset.
Common usage
influx setup --force \
--org acme --bucket app \
--username admin --password "ci-password-123" \
--token ci-token --retention 0Options
| Flag | What it does |
|---|---|
| -f, --force | Skip the interactive confirmation prompt |
| -o, --org <name> | Initial organization name |
| -b, --bucket <name> | Initial bucket name |
| -u, --username <name> | Initial admin username |
| -p, --password <pw> | Initial admin password (min length applies) |
| -t, --token <token> | Operator token to assign (otherwise generated) |
| -r, --retention <dur> | Retention for the initial bucket (0 = infinite) |
In CI
Always pass --force so setup does not block on the confirmation prompt. Supplying --token with a known value lets later steps and the app share one token without parsing the generated one. The official influxdb:2 image can also run setup automatically from DOCKER_INFLUXDB_INIT_* environment variables, which avoids a separate setup step.
Common errors in CI
"Error: instance has already been set up" means setup ran already (or the image auto-initialized via env vars); treat it as success and skip. "password is too short" means the password is under the minimum length (8 characters). "Error: failed to setup instance: 422 Unprocessable Entity" usually means a missing required flag such as --org or --bucket.