influxdb
1B+
InfluxDB is the open source time series database built for real-time analytic workloads.
docker pull influxdb
Note: the description for this image is longer than the Hub length limit of 25000, so has been trimmed. The full description can be found at https://github.com/docker-library/docs/tree/master/influxdb/README.md. See also docker/hub-feedback#238 and docker/roadmap#475.
Maintained by:
InfluxData
Where to get help:
the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow
Dockerfile
linksWhere to file issues:
https://github.com/influxdata/influxdata-docker/issues
Supported architectures: (more info)amd64
, arm64v8
Published image artifact details:
repo-info repo's repos/influxdb/
directory (history)
(image metadata, transfer size, etc)
Image updates:
official-images repo's library/influxdb
label
official-images repo's library/influxdb
file (history)
Source of this description:
docs repo's influxdb/
directory (history)
InfluxDB is the time series data platform designed to handle high write and query workloads. Using InfluxDB, you can collect, store, and process large amounts of timestamped data, including metrics and events for use cases such as DevOps monitoring, application metrics, IoT sensors, and event monitoring.
Use the InfluxDB Docker Hub image to write, query, and process time series data in InfluxDB v2 or InfluxDB v1.
For more information, visit https://influxdata.com.
Quick start: See the guide to Install InfluxDB v2 for Docker and get started using InfluxDB v2.
To start an InfluxDB v2 container, enter the following command:
docker run \
-p 8086:8086 \
-v "$PWD/data:/var/lib/influxdb2" \
-v "$PWD/config:/etc/influxdb2" \
influxdb:2
Replace the following with your own values:
$PWD/data
: A host directory to mount at the container's InfluxDB data directory path$PWD/config
: A host directory to mount at the container's InfluxDB configuration directory pathAfter the container starts, the InfluxDB UI and API are accessible at http://localhost:8086 on the host. You're ready to set up an initial admin user, token, and bucket from outside or inside the container--choose one of the following:
Set up InfluxDB from outside the container: Set up InfluxDB from the host or network using the InfluxDB UI, influx
CLI, or HTTP API.
Set up InfluxDB from inside the container: Use docker exec
to run the influx
CLI installed in the container--for example:
docker exec influxdb2 influx setup \
--username $USERNAME \
--password $PASSWORD \
--org $ORGANIZATION \
--bucket $BUCKET \
--force
See the influx setup
documentation for the full list of options.
If you run setup from within the container, InfluxDB stores influx
CLI connection configurations in the container's /etc/influxdb2/influx-configs
file.
To start and set up InfluxDB v2 with a single command, specify -e DOCKER_INFLUXDB_INIT_MODE=setup
and -e DOCKER_INFLUXDB_INIT_
environment variables for the initial user, password, bucket, and organization--for example:
docker run -d -p 8086:8086 \
-v "$PWD/data:/var/lib/influxdb2" \
-v "$PWD/config:/etc/influxdb2" \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=<USERNAME> \
-e DOCKER_INFLUXDB_INIT_PASSWORD=<PASSWORD> \
-e DOCKER_INFLUXDB_INIT_ORG=<ORG_NAME> \
-e DOCKER_INFLUXDB_INIT_BUCKET=<BUCKET_NAME> \
influxdb:2
Replace the following with your own values:
$PWD/data
: A host directory to mount at the container's InfluxDB data directory path$PWD/config
: A host directory to mount at the container's InfluxDB configuration directory path<USERNAME>
: A name for your initial admin user<PASSWORD>
: A password for your initial admin user<ORG_NAME>
: A name for your initial organization<BUCKET_NAME>
: A name for your initial bucket (database)If you run setup from within the container, InfluxDB stores influx
CLI connection configurations in the container's /etc/influxdb2/influx-configs
file.
In setup mode (DOCKER_INFLUXDB_INIT_MODE=setup
) or upgrade mode (DOCKER_INFLUXDB_INIT_MODE=upgrade
), you can specify the following Docker-specific environment variables to provide initial setup values:
DOCKER_INFLUXDB_INIT_USERNAME
: A name for your initial admin user.DOCKER_INFLUXDB_INIT_PASSWORD
: A password for your initial admin user.DOCKER_INFLUXDB_INIT_ORG
: A name for your initial organization.DOCKER_INFLUXDB_INIT_BUCKET
: A name for your initial bucket.DOCKER_INFLUXDB_INIT_RETENTION
: A duration to use as the initial bucket's retention period. Default: 0
(infinite; doesn't delete data).DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
: A string value to set for the Operator token. Default: a generated token.The following example shows how to pass values for all initial setup options:
docker run -d -p 8086:8086 \
-v "$PWD/data:/var/lib/influxdb2" \
-v "$PWD/config:/etc/influxdb2" \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=my-org \
-e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
-e DOCKER_INFLUXDB_INIT_RETENTION=1w \
-e DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token \
influxdb:2
*To upgrade from InfluxDB 1.x to InfluxDB 2.x, see the Upgrading from InfluxDB 1.x section below.*
With InfluxDB set up and running, see the Get started tutorial to create tokens and write and query data.
In setup
mode (DOCKER_INFLUXDB_INIT_MODE=setup
) or upgrade
mode (DOCKER_INFLUXDB_INIT_MODE=upgrade
), the InfluxDB Docker Hub image supports running custom initialization scripts. After the setup process completes, scripts are executed in lexical sort order by name.
For the container to run scripts, they must:
Be mounted in the container's /docker-entrypoint-initdb.d
directory
Be named using the .sh
file name extension
Be executable by the user running the docker run
command--for example, to allow the current use to execute a script with docker run
:
chmod +x ./scripts/<yourscript.sh>
Grant permissions to mounted files
By default, Docker runs containers using the user and group IDs of the user executing the
docker run
command. When files are bind-mounted into the container, Docker preserves the user and group ownership from the host system.
The image exports a number of variables into the environment before executing scripts. The following variables are available for you to use in your scripts:
INFLUX_CONFIGS_PATH
: Path to the influx
CLI connection configurations file written by setup
/upgrade
INFLUX_HOST
: URL to the influxd
instance running setup
/upgrade
DOCKER_INFLUXDB_INIT_USER_ID
: ID of the initial admin user created by setup
/upgrade
DOCKER_INFLUXDB_INIT_ORG_ID
: ID of the initial organization created by setup
/upgrade
DOCKER_INFLUXDB_INIT_BUCKET_ID
: ID of the initial bucket created by setup
/upgrade
For example, to grant an InfluxDB 1.x client write permission to your initial bucket, create a $PWD/scripts/setup-v1.sh
file that contains the following:
#!/bin/bash
set -e
influx v1 dbrp create \
--bucket-id ${DOCKER_INFLUXDB_INIT_BUCKET_ID} \
--db ${V1_DB_NAME} \
--rp ${V1_RP_NAME} \
--default \
--org ${DOCKER_INFLUXDB_INIT_ORG}
influx v1 auth create \
--username ${V1_AUTH_USERNAME} \
--password ${V1_AUTH_PASSWORD} \
--write-bucket ${DOCKER_INFLUXDB_INIT_BUCKET_ID} \
--org ${DOCKER_INFLUXDB_INIT_ORG}
Then, run the following command to start and set up InfluxDB using custom scripts:
docker run -p 8086:8086 \
-v "$PWD/data:/var/lib/influxdb2" \
-v "$PWD/config:/etc/influxdb2" \
-v "$PWD/scripts:/docker-entrypoint-initdb.d" \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=my-org \
-e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
-e V1_DB_NAME=v1-db \
-e V1_RP_NAME=v1-rp \
-e V1_AUTH_USERNAME=v1-user \
-e V1_AUTH_PASSWORD=v1-password \
influxdb:2
Automated setup and upgrade ignored if already setup
Automated
setup
,upgrade
, and custom initialization scripts won't run if an existinginfluxd.bolt
boltdb file from a previous setup is found in the configured data directory.This behavior allows for the InfluxDB container to reboot post-setup and avoid overwriting migrated data,
DB is already set up
errors, and errors from non-idempotent script commands.
When starting an InfluxDB container, we recommend the following for easy access to your data, configurations, and InfluxDB v2 instance:
8086
port to make the InfluxDB UI and HTTP API accessible from the host system.For InfluxDB v2, the InfluxDB Docker Hub image uses the following default ports and file system paths:
TCP port 8086
: the default port for the InfluxDB UI and HTTP API. To specify a different port or address, use the http-bind-address
configuration option.
/var/lib/influxdb2/
: the InfluxDB data directory
/engine/
: Default InfluxDB Storage engine pathinfluxd.bolt
: Default Bolt pathinfluxd.sqlite
: Default SQLite path/etc/influxdb2
: the InfluxDB configuration directory
/etc/influxdb2/configs
: influx
CLI connection configurations file/etc/influxdb2/influx-configs
: influx
CLI connection configurations file, if you run setup from within the container/etc/influxdb2/config.[yml, json, toml]
: Your customized InfluxDB configuration options fileTo customize InfluxDB, specify server configuration options in a configuration file, environment variables, or command line flags.
Use a configuration file
To customize and mount an InfluxDB configuration file, do the following:
If you haven't already, set up InfluxDB to initialize an API Operator token. You'll need the Operator token in the next step.
Run the influx server-config
CLI command to output the current server configuration to a file in the mounted configuration directory--for example, enter the following command to use the container's influx
CLI and default Operator token:
docker exec -it influxdb2 influx server-config > "$PWD/config/config.yml"
Replace $PWD/config/
with the host directory that you mounted at the container's /etc/influxdb2
InfluxDB configuration directory path.
Edit the config.yml
file to customize server configuration options.
Restart the container.
docker restart influxdb2
Use environment variables and command line flags
To override specific configuration options, use environment variables or command line flags.
Pass INFLUXD_
environment variables to Docker to override the configuration file--for example:
docker run -p 8086:8086 \
-e INFLUXD_STORAGE_WAL_FSYNC_DELAY=15m \
influxdb:2
Pass influxd
command line flags to override environment variables and the configuration file--for example:
docker run -p 8086:8086 \
influxdb:2 --storage-wal-fsync-delay=15m
To learn more, see InfluxDB configuration options.
InfluxDB 2.x provides a 1.x-compatible API, but expects a different storage layout on disk. To account for these differences, the InfluxDB Docker Hub image provides an upgrade
feature that migrates 1.x data and configuration to 2.x before starting the influxd
server.
The automated upgrade process creates the following in the InfluxDB v2 container:
/var/lib/influxdb2
)/etc/influxdb2
)Mount volumes at both paths to avoid losing data.
To run the automated upgrade, specify the following when you start the container:
InfluxDB v2 initialization environment variables:
DOCKER_INFLUXDB_INIT_MODE=upgrade
DOCKER_INFLUXDB_INIT_USERNAME
: A name for the initial admin userDOCKER_INFLUXDB_INIT_PASSWORD
: A password for the initial admin userDOCKER_INFLUXDB_INIT_ORG
: A name for the initial organizationDOCKER_INFLUXDB_INIT_BUCKET
: A name for the initial bucketDOCKER_INFLUXDB_INIT_RETENTION
: A duration for the bucket retention period. Default: 0
(infinite; doesn't delete data)DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
: A value to set for the Operator token. Default: generates a token.1.x data and configuration paths:
DOCKER_INFLUXDB_INIT_UPGRADE_V1_DIR
environment variable or mounted at /var/lib/influxdb
DOCKER_INFLUXDB_INIT_UPGRADE_V1_CONFIG
environment variable or mounted at /etc/influxdb/influxdb.conf
The upgrade process searches for mounted 1.x data and configuration paths in the following order of precedence:
DOCKER_INFLUXDB_INIT_UPGRADE_V1_CONFIG
environment variableDOCKER_INFLUXDB_INIT_UPGRADE_V1_DIR
environment variable/etc/influxdb/influxdb.conf
/var/lib/influxdb
Automated setup and upgrade ignored if already setup
Automated
setup
,upgrade
, and custom initialization scripts won't run if an existinginfluxd.bolt
boltdb file from a previous setup is found in the configured data directory.This behavior allows for the InfluxDB container to reboot post-setup and avoid overwriting migrated data,
DB is already set up
errors, and errors from non-idempotent script commands.
Upgrade InfluxDB 1.x: default data path and configuration
Assume you've been running a minimal InfluxDB 1.x deployment:
docker run -p 8086:8086 \
-v influxdb:/var/lib/influxdb \
influxdb:1.8
To upgrade this deployment to InfluxDB 2.x, stop the running InfluxDB 1.x container, and then run the following command:
docker run -p 8086:8086 \
-v influxdb:/var/lib/influxdb \
-v influxdb2:/var/lib/influxdb2 \
-e DOCKER_INFLUXDB_INIT_MODE=upgrade \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=my-org \
-e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
influxdb:2
Upgrade InfluxDB 1.x: custom configuration
Assume you've been running an InfluxDB 1.x deployment with customized configuration (/etc/influxdb/influxdb.conf
):
docker run -p 8086:8086 \
-v influxdb:/var/lib/influxdb \
-v "$PWD/influxdb.conf:/etc/influxdb/influxdb.conf" \
influxdb:1.8
To upgrade this deployment to InfluxDB 2.x, stop the running InfluxDB 1.x container, and then run the following command:
docker run -p 8086:8086 \
-v influxdb:/var/lib/influxdb \
-v influxdb2:/var/lib/influxdb2 \
-v influxdb2-config:/etc/influxdb2 \
-v "$PWD/influxdb.conf:/etc/influxdb/influxdb.conf" \
-e DOCKER_INFLUXDB_INIT_MODE=upgrade \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=my-org \
-e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
influxdb:2
Upgrade InfluxDB 1.x: custom data and configuration paths
Assume you've been running an InfluxDB 1.x deployment with data and configuration mounted at custom paths:
docker run -p 8086:8086 \
-v influxdb:/root/influxdb/data \
-v "$PWD/influxdb.conf:/root/influxdb/influxdb.conf" \
influxdb:1.8 -config /root/influxdb/influxdb.conf
Before you upgrade to InfluxDB v2, decide whether to keep using your custom paths or to use the InfluxDB v2 defaults.
To use InfluxDB v2 defaults, stop the running InfluxDB 1.x container, and then run the following command:
docker run -p 8086:8086 \
-v influxdb:/root/influxdb/data \
-v influxdb2:/var/lib/influxdb2 \
-v influxdb2-config:/etc/influxdb2 \
-v "$PWD/influxdb.conf:/root/influxdb/influxdb.conf" \
-e DOCKER_INFLUXDB_INIT_MODE=upgrade \
-e DOCKER_INFLUXDB_INIT_USERNAME=my-user \
-e DOCKER_INFLUXDB_INIT_PASSWORD=my-password \
-e DOCKER_INFLUXDB_INIT_ORG=my-org \
-e DOCKER_INFLUXDB_INIT_BUCKET=my-bucket \
-e DOCKER_INFLUXDB_INIT_UPGRADE_V1_CONFIG=/root/influxdb/influxdb.conf \
influxdb:2
To use your custom paths instead of InfluxDB v2 default paths, run the following command:
...
Note: the description for this image is longer than the Hub length limit of 25000, so has been trimmed. The full description can be found at https://github.com/docker-library/docs/tree/master/influxdb/README.md. See also docker/hub-feedback#238 and docker/roadmap#475.
Docker Official Images are a curated set of Docker open source and drop-in solution repositories.
These images have clear documentation, promote best practices, and are designed for the most common use cases.