We are living as nomad in Mexico !!

Build influxdb with docker-compose

You can see the following
  • How to build build influxdb with docker-compose

Table of contents

File structure

console
docker
  .env
  config
    config.yml
  data
  docker-compose.yaml
  • docker/config/config.yml: influxdb configuration file

Create .env

Create the `.env` to set the Docker project name.

.env
COMPOSE_PROJECT_NAME=influxdb-test

Create influxdb configuration file

In this time, I use version 2.7.
You can use the Docker official image for influxdb as below:

influxdb Docker official URL

console
> docker run --rm influxdb:2.7 influxd print-config > docker/config/config.yml

Create docker-compose.yaml

docker-compose.yaml
services:
  influxdb-test:
    image: influxdb:2.7
    container_name: influxdb-test
    volumes:
      - ./data/influxdb2:/var/lib/influxdb2
      - ./config/config.yml:/etc/influxdb2/config.yml
    ports:
      - 8086:8086
    environment:
      DOCKER_INFLUXDB_INIT_MODE: setup
      DOCKER_INFLUXDB_INIT_USERNAME: my-user
      DOCKER_INFLUXDB_INIT_PASSWORD: my-password
      DOCKER_INFLUXDB_INIT_ORG: my-org
      DOCKER_INFLUXDB_INIT_BUCKET: my-bucket
      DOCKER_INFLUXDB_INIT_RETENTION: 1w
      DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: my-super-secret-auth-token

Start up Docker conteiner for influxdb

console
> docker-compose --file docker/docker-compose.yaml up -d           
Creating network "influxdb-test_default" with the default driver
Creating influxdb-test ... done

Check the Docker image, container and network for influxdb.

console
> docker image ls
REPOSITORY  TAG  IMAGE ID      CREATED      SIZE
influxdb    2.7  55857d99abe6  2 weeks ago  266MB

> docker container ls -a
CONTAINER ID  IMAGE         COMMAND                 CREATED             STATUS             PORTS                   NAMES
d98871fffb6a  influxdb:2.7  "/entrypoint.sh infl…"  About a minute ago  Up About a minute  0.0.0.0:8086->8086/tcp  influxdb-test

> docker network ls
NETWORK ID    NAME                   DRIVER  SCOPE
9bef0fcd65f5  influxdb-test_default  bridge  local

Check the Docker process for influxdb.

console
> docker ps
CONTAINER ID  IMAGE         COMMAND                 CREATED        STATUS        PORTS                   NAMES
d98871fffb6a  influxdb:2.7  "/entrypoint.sh infl…"  5 minutes ago  Up 5 minutes  0.0.0.0:8086->8086/tcp  influxdb-test

Access to influxdb web application

Access to the `http://localhost:8086` and then you can see the toppage of influxdb.
Input your username and password which is set in `docker-compose.yaml`

  • Username: DOCKER_INFLUXDB_INIT_USERNAME
  • Password: DOCKER_INFLUXDB_INIT_PASSWORD
influxdb login page

Now, you are able to develop with influxdb from this page!!

influxdb get started page

🌟The author of this article is:🌟

Kakeru profile

Kakeru Sato

Software Developer

Full stack engineer