How to Install InfluxDB using Docker

October 9, 2023

Setup InfluxDB

Create directory and navigate to it:

mkdir influxdb
cd influxdb

Docker Compose Configuration

Create docker-compose.yml file:

version: '3.8'

services:
  influxdb:
    image: quay.io/influxdb/influxdb:v2.0.4
    ports:
      - "8086:8086"
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=admin
      - DOCKER_INFLUXDB_INIT_PASSWORD=adminpassword
      - DOCKER_INFLUXDB_INIT_ORG=mycompany
      - DOCKER_INFLUXDB_INIT_BUCKET=geoip2influx
    volumes:
      - ./influxdb-data:/var/lib/influxdb2
    networks:
      - influxdb-net

networks:
  influxdb-net:

Install InfluxDB Client

Download and install the client:

wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.7.3-linux-amd64.tar.gz
tar xvzf influxdb2-client-2.7.3-linux-amd64.tar.gz
sudo cp influx /usr/local/bin/

Configure InfluxDB Client

Create client configuration:

influx config create \
    --config-name defaul-config \
    --host-url http://localhost:8086 \
    --org mycompany \
    --token KIRocbUKK8dQ1knGakgs_QUtXqsbzH0b_YACP83Jqzl8nyc6Pye_dVK_yFO6RK_GX53kRwqu2ddxqHXEXG-b7nUQ== \
    --active

Configuration Details

  • Port: 8086
  • Version: v2.0.4
  • Default Credentials:
    • Username: admin
    • Password: adminpassword
  • Organization: mycompany
  • Default Bucket: geoip2influx

Verification Steps

  1. Start the containers:
    docker-compose up -d
  2. Check container status:
    docker ps | grep influxdb
  3. Access web interface:
    http://localhost:8086

Best Practices

  • Secure your token
  • Regular backups of data volume
  • Monitor disk usage
  • Set up retention policies
#InfluxDB #Docker #Database #Monitoring #TimeSeries