-
Maintained by:
InfluxData -
Where to get help:
the Docker Community Slack, Server Fault, Unix & Linux, or Stack Overflow
-
Where to file issues:
https://github.com/influxdata/influxdata-docker/issues -
Supported architectures: (more info)
amd64
,arm32v7
,arm64v8
-
Published image artifact details:
repo-info repo'srepos/influxdb/
directory (history)
(image metadata, transfer size, etc) -
Image updates:
official-images repo'slibrary/influxdb
label
official-images repo'slibrary/influxdb
file (history) -
Source of this description:
docs repo'sinfluxdb/
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 path
After 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 theinflux
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.- Optional:
DOCKER_INFLUXDB_INIT_RETENTION
: A duration to use as the initial bucket's retention period. Default:0
(infinite; doesn't delete data). - Optional:
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 withdocker run
:chmod +x ./scripts/<yourscript.sh>
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 theinflux
CLI connection configurations file written bysetup
/upgrade
INFLUX_HOST
: URL to theinfluxd
instance runningsetup
/upgrade
DOCKER_INFLUXDB_INIT_USER_ID
: ID of the initial admin user created bysetup
/upgrade
DOCKER_INFLUXDB_INIT_ORG_ID
: ID of the initial organization created bysetup
/upgrade
DOCKER_INFLUXDB_INIT_BUCKET_ID
: ID of the initial bucket created bysetup
/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
,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:
- Publish the container's
8086
port to make the InfluxDB UI and HTTP API accessible from the host system. - Use Docker Volumes or Bind mounts to persist InfluxDB data and configuration directories outside of containers.
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 thehttp-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- Optional:
/etc/influxdb2/config.[yml, json, toml]
: Your customized InfluxDB configuration options file
To customize InfluxDB, specify server configuration options in a configuration file, environment variables, or command line flags.
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'sinflux
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
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:
- an initial admin user
- an initial organization
- an initial bucket
- InfluxDB v2 data files (the default path is
/var/lib/influxdb2
) - InfluxDB v2 configuration files (the default path is
/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 bucket- Optional:
DOCKER_INFLUXDB_INIT_RETENTION
: A duration for the bucket retention period. Default:0
(infinite; doesn't delete data) - Optional:
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
: A value to set for the Operator token. Default: generates a token.
-
1.x data and configuration paths:
- A 1.x data volume, specified by the
DOCKER_INFLUXDB_INIT_UPGRADE_V1_DIR
environment variable or mounted at/var/lib/influxdb
- Optional: a 1.x custom configuration file, specified by the
DOCKER_INFLUXDB_INIT_UPGRADE_V1_CONFIG
environment variable or mounted at/etc/influxdb/influxdb.conf
- A 1.x data volume, specified by the
The upgrade process searches for mounted 1.x data and configuration paths in the following order of precedence:
- A configuration file referenced by the
DOCKER_INFLUXDB_INIT_UPGRADE_V1_CONFIG
environment variable - A data directory referenced by the
DOCKER_INFLUXDB_INIT_UPGRADE_V1_DIR
environment variable - A configuration file mounted at
/etc/influxdb/influxdb.conf
- A data directory mounted at
/var/lib/influxdb
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.
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
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
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:
docker run -p 8086:8086 \
-v influxdb:/root/influxdb/data \
-v influxdb2:/root/influxdb2/data \
-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 \
-e DOCKER_INFLUXDB_CONFIG_PATH=/root/influxdb2/config.toml \
-e DOCKER_INFLUXDB_BOLT_PATH=/root/influxdb2/influxdb.bolt \
-e DOCKER_INFLUXDB_ENGINE_PATH=/root/influxdb2/engine \
influxdb:2
To learn more about the upgrade process, see the v1-to-v2 upgrade guide.
Early Docker builds of InfluxDB 2.x were hosted at quay.io/influxdb/influxdb
and contained the influx
and influxd
binaries without any default configuration or helper scripts. By default, the influxd
process stored data in /root/.influxdbv2
.
Starting with v2.0.4
, we restored the InfluxDB Docker Hub build, which defaults to storing data in /var/lib/influxdb2
. If you upgrade directly from quay.io/influxdb/influxdb
to influxdb:2.0.4
using the default settings, InfluxDB won't be able to find your existing data files.
To avoid this problem when migrating from quay.io/influxdb/influxdb
to influxdb:2.0
, choose one of the following:
To use the InfluxDB Docker Hub data path, start a container that mounts your data volume into /var/lib/influxdb2
--for example, if you used the following command to start the InfluxDB quay.io container:
# quay.io InfluxDB 2.x container
docker run -p 8086:8086 \
-v "$PWD:/root/.influxdbv2" \
quay.io/influxdb/influxdb:v2.0.3
Use this command to start an InfluxDB v2 Docker Hub container:
# Docker Hub InfluxDB 2.x container
docker run -p 8086:8086 \
-v "$PWD:/var/lib/influxdb2" \
influxdb:2
To continue using the /root/.influxdbv2
data path, customize storage path configuration options (bolt-path, engine-path, sqlite-path) configuration options for your InfluxDB Docker Hub container--for example, if you used the following command to start the InfluxDB quay.io container:
# quay.io-hosted InfluxDB 2.x
docker run -p 8086:8086 \
-v "$PWD:/root/.influxdbv2" \
quay.io/influxdb/influxdb:v2.0.3
Use this command to start an InfluxDB v2 Docker Hub container:
docker run -p 8086:8086 \
-e INFLUXD_BOLT_PATH=/root/.influxdbv2/influxd.bolt \
-e INFLUXD_ENGINE_PATH=/root/.influxdbv2/engine \
-v "$PWD:/root/.influxdbv2" \
influxdb:2
Use the InfluxDB Docker Hub image to run and set up an InfluxDB 1.x container.
To start an InfluxDB 1.x container, enter the following command:
docker run -p 8086:8086 \
-v "$PWD:/var/lib/influxdb" \
influxdb:1.8
The command passes the following arguments:
-p 8086:8086
: Exposes the InfluxDB HTTP API on host port8086
.-v $PWD:/var/lib/influxdb
: Mounts the host's$PWD
directory to the InfluxDB data directory to persist data outside the container.
Replace $PWD
with the host directory where you want InfluxDB to store data.
Use Docker Volumes or Bind mounts to persist InfluxDB data and configuration directories.
InfluxDB uses the following networking ports:
- TCP port
8086
: the default port for the HTTP API - TCP port
2003
: the port for the Graphite protocol (if enabled)
Using the docker run
-P, --publish-all
flag exposes the InfluxDB HTTP API to the host.
To configure InfluxDB v1 in a container, use a configuration file or environment variables.
To customize and mount a configuration file, do the following:
-
Output the current server configuration to a file in the mounted configuration directory--for example:
docker run --rm influxdb:1.8 influxd config > influxdb.conf
-
Edit the
influxdb.conf
file to customize server configuration options.docker run -p 8086:8086 \ -v "$PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro" \ influxdb:1.8 -config /etc/influxdb/influxdb.conf
Replace
$PWD
with the host directory where you want to store the configuration file.
Pass INFLUXDB_
environment variables to override specific InfluxDB v1 configuration options. An environment variable overrides the equivalent option in the configuration file.
docker run -p 8086:8086 \
-e INFLUXDB_REPORTING_DISABLED=true \
-e INFLUXDB_META_DIR=/path/to/metadir \
-e INFLUXDB_DATA_QUERY_LOG_ENABLED=false \
influxdb:1.8
Learn more about configuring InfluxDB v1.
InfluxDB supports the Graphite line protocol, but the service and ports are not exposed by default. To run InfluxDB with Graphite support enabled, you can either use a configuration file or set the appropriate environment variables. Run InfluxDB with the default Graphite configuration:
docker run -p 8086:8086 -p 2003:2003 \
-e INFLUXDB_GRAPHITE_ENABLED=true \
influxdb:1.8
See the README on GitHub for more detailed documentation to set up the Graphite service. In order to take advantage of graphite templates, you should use a configuration file by outputting a default configuration file using the steps above and modifying the [[graphite]]
section.
Creating a DB named mydb:
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
Inserting into the DB:
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
Read more about this in the official documentation.
Start the container:
docker run --name=influxdb -d -p 8086:8086 influxdb:1.8
Run the influx client in this container:
docker exec -it influxdb influx
Or run the influx client in a separate container:
docker run --rm --link=influxdb -it influxdb:1.8 influx -host influxdb
We don't recommend using initialization options for InfluxDB v1 production scenarios, but they're useful when running standalone instances for testing.
The InfluxDB Docker Hub image lets you set initialization options when creating an InfluxDB v1 container.
The database initialization script is only called when running influxd
; it isn't executed by any other program.
During the InfluxDB v1 set up process, the InfluxDB image uses environment variables to automatically configure some server options. You can override the following environment variables to customize set up options.
Automatically initializes a database with the name of this environment variable.
Enables authentication. Either this must be set or auth-enabled = true
must be set within the configuration file for any authentication-related options below to work.
The name of the admin user to be created. If this is unset, no admin user is created.
The password for the admin user configured with INFLUXDB_ADMIN_USER
. If this is unset, a random password is generated and printed to standard out.
The name of a user to be created with no privileges. If INFLUXDB_DB
is set, this user will be granted read and write permissions for that database.
The password for the user configured with INFLUXDB_USER
. If this is unset, a random password is generated and printed to standard out.
The name of a user to be created with read privileges on INFLUXDB_DB
. If INFLUXDB_DB
is not set, this user will have no granted permissions.
The password for the user configured with INFLUXDB_READ_USER
. If this is unset, a random password is generated and printed to standard out.
The name of a user to be created with write privileges on INFLUXDB_DB
. If INFLUXDB_DB
is not set, this user will have no granted permissions.
The password for the user configured with INFLUXDB_WRITE_USER
. If this is unset, a random password is generated and printed to standard out.
If the Docker image finds any files with the extensions .sh
or .iql
inside of the /docker-entrypoint-initdb.d
folder, it will execute them. The order they are executed in is determined by the shell. This is usually alphabetical order.
To manually initialize an InfluxDB v1 database, use docker run
to call the /init-influxdb.sh
script directly. The script takes the same initialization options as the influxd run
command--for example:
docker run --rm \
-e INFLUXDB_DB=db0 \
-e INFLUXDB_ADMIN_USER=admin \
-e INFLUXDB_ADMIN_PASSWORD=supersecretpassword \
-e INFLUXDB_USER=telegraf -e \
-e INFLUXDB_USER_PASSWORD=secretpassword \
-v "$PWD:/var/lib/influxdb" \
influxdb:1.8 /init-influxdb.sh
The command creates the following:
- a database named
db0
- an admin user
admin
with the passwordsupersecretpassword
- a
telegraf
user with the passwordsecretpassword
The --rm
flag causes Docker to exit and delete the container after the script runs. The data and configuration files created during initialization remain in the mounted volume (the host's $PWD
directory).
The influxdb
images come in many flavors, each designed for a specific use case.
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.
This image is based on the popular Alpine Linux project, available in the alpine
official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.
This variant is useful when final image size being as small as possible is your primary concern. The main caveat to note is that it does use musl libc instead of glibc and friends, so software will often run into issues depending on the depth of their libc requirements/assumptions. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.
To minimize image size, it's uncommon for additional related tools (such as git
or bash
) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine
image description for examples of how to install packages if you are unfamiliar).
Using this image for InfluxDB Enterprise requires a valid InfluxData license key.
This image contains the enterprise data node package for clustering. It supports all of the same options as the InfluxDB 1.x OSS image, but it needs port 8088 to be exposed to the meta nodes.
Refer to the influxdb:meta
variant for directions on how to setup a cluster.
This image requires a valid license key from InfluxData. Please visit our products page to learn more.
This image contains the enterprise meta node package for clustering. It is meant to be used in conjunction with the influxdb:data
package of the same version.
The license key can be specified using either an environment variable or by overriding the configuration file. If you specify the license key directly, the container needs to be able to access the InfluxData portal.
docker run -p 8089:8089 -p 8091:8091 \
-e INFLUXDB_ENTERPRISE_LICENSE_KEY=<license-key>
influxdb:meta
The examples below will use docker's built-in networking capability. If you use the port exposing feature, the host port and the container port need to be the same.
First, create a docker network:
docker network create influxdb
Start three meta nodes. This is the suggested number of meta nodes. We do not recommend running more or less. If you choose to run more or less, be sure that the number of meta nodes is odd. The hostname must be set on each container to the address that will be used to access the meta node. When using docker networks, the hostname should be made the same as the name of the container.
docker run -d --name=influxdb-meta-0 --network=influxdb \
-h influxdb-meta-0 \
-e INFLUXDB_ENTERPRISE_LICENSE_KEY=<license-key> \
influxdb:meta
docker run -d --name=influxdb-meta-1 --network=influxdb \
-h influxdb-meta-1 \
-e INFLUXDB_ENTERPRISE_LICENSE_KEY=<license-key> \
influxdb:meta
docker run -d --name=influxdb-meta-2 --network=influxdb \
-h influxdb-meta-2 \
-e INFLUXDB_ENTERPRISE_LICENSE_KEY=<license-key> \
influxdb:meta
When setting the hostname, you can use -h <hostname>
or you can directly set the environment variable using -e INFLUXDB_HOSTNAME=<hostname>
.
After starting the meta nodes, you need to tell them about each other. Choose one of the meta nodes and run influxd-ctl
in the container.
docker exec influxdb-meta-0 \
influxd-ctl add-meta influxdb-meta-1:8091
docker exec influxdb-meta-0 \
influxd-ctl add-meta influxdb-meta-2:8091
Or you can just start a single meta node. If you setup a single meta node, you do not need to use influxd-ctl add-meta
.
docker run -d --name=influxdb-meta --network=influxdb \
-h influxdb-meta \
-e INFLUXDB_ENTERPRISE_LICENSE_KEY=<license-key> \
influxdb:meta -single-server
Start the data nodes using influxdb:data
with similar command line arguments to the meta nodes. You can start as many data nodes as are allowed by your license.
docker run -d --name=influxdb-data-0 --network=influxdb \
-h influxdb-data-0 \
-e INFLUXDB_LICENSE_KEY=<license-key> \
influxdb:data
You can add -p 8086:8086
to expose the http port to the host machine. After starting the container, choose one of the meta nodes and add the data node to it.
docker exec influxdb-meta-0 \
influxd-ctl add-data influxdb-data-0:8088
Perform these same steps for any other data nodes that you want to add.
You can now connect to any of the running data nodes to use your cluster.
See the influxdb image documentation for more details on how to use the data node images.
InfluxDB Meta can be either configured from a config file or using environment variables. To mount a configuration file and use it with the server, you can use this command:
Generate the default configuration file:
docker run --rm influxdb:meta influxd-meta config > influxdb-meta.conf
Modify the default configuration, which will now be available under $PWD
. Then start the InfluxDB Meta container.
docker run \
-v $PWD/influxdb-meta.conf:/etc/influxdb/influxdb-meta.conf:ro \
influxdb -config /etc/influxdb/influxdb-meta.conf
Modify $PWD
to the directory where you want to store the configuration file.
For environment variables, the format is INFLUXDB_$SECTION_$NAME
. All dashes (-
) are replaced with underscores (_
). If the variable isn't in a section, then omit that part.
Examples:
INFLUXDB_REPORTING_DISABLED=true
INFLUXDB_META_DIR=/path/to/metadir
INFLUXDB_ENTERPRISE_REGISTRATION_ENABLED=true
For more information, see how to Install InfluxDB Enterprise meta nodes.
View license information for the software contained in this image.
As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).
Some additional license information which was able to be auto-detected might be found in the repo-info
repository's influxdb/
directory.
As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.