How to Install InfluxDB using Docker
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
- Start the containers:
docker-compose up -d
- Check container status:
docker ps | grep influxdb
- Access web interface:
http://localhost:8086
Best Practices
- Secure your token
- Regular backups of data volume
- Monitor disk usage
- Set up retention policies