Mounting V2.7.0 non-Docker data to v2.7.5 Docker container

Hey,

I am struggling for the last couple of days to move my current stand-alone influx (V2.7.0) installation to Docker (V2.7.5). I am trying to mount my current non-Docker data and config files to Docker volumes:

version: '3'

services:

  influxdb:
    image: influxdb:2.7.5
    container_name: influxdb
    env_file:
      - ./env-files/influxdb.env
    volumes:
      - ./influxdb/data:/var/lib/influxdb2
      - ./influxdb/config:/etc/influxdb2
    ports:
      - "8086:8086"
    networks:
      - tig-net

  grafana:
    image: grafana/grafana:10.4.1-ubuntu
    container_name: grafana
    env_file:
      - ./env-files/grafana.env
    volumes:
      - ./grafana/data:/var/lib/grafana
    depends_on:
      - influxdb
    ports:
      - "3000:3000"
    restart: always
    networks:
      - tig-net
    user: "1000:1000"

networks:
  tig-net:
    name: tig-net
    driver: bridge

env-file

DOCKER_INFLUXDB_INIT_MODE=setup
DOCKER_INFLUXDB_INIT_USERNAME=al
DOCKER_INFLUXDB_INIT_PASSWORD=pass
DOCKER_INFLUXDB_INIT_ORG=org
DOCKER_INFLUXDB_INIT_BUCKET=main
DOCKER_INFLUXDB_INIT_RETENTION=0
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=token

What happens is that I simply copy and paste config and data dirs to appropriate Docker volumes (i.e. host folders). However, each time it loads a container, it runs setup and no data, no configuration is kept. Is it possible to move influx this way to Docker at all? I also tried the same version of container V2.7.0, but no luck. I have also tried to move CLI configurations into influx-configs files, but also that did not help and I also got error that default configuration already exists.

Thanks

@roflas I don’t believe your volume paths are correct according to the InfluxDB fs layout for Docker. I think it should be:

# ...
    volumes:
      - ./influxdb/data:/var/lib/influxdb2/engine/
      - ./influxdb/config:/etc/influxdb2/
1 Like

Thanks for reply.

I followed this manual: https://hub.docker.com/_/influxdb

And it says that dirs should be like the ones I used. Am I wrong? If I used your version, how would it know and find *.bolt file with last setup? Manual says that if it does not find one, it will rerun setup again.

Ah, I see. ./influxdb/data contains all the data (both time series and metadata). And you’ve confirmed that the following exist in your local fs?

  • ./influxdb/data/engine/
  • ./influxdb/data/engine/data/
  • ./influxdb/data/engine/wal/
  • ./influxdb/data/influxd.bolt
  • ./influxdb/data/influxd.sqlite

Yes, I can confirm that all of those dirs do actually exist on host fs.

Try starting the container without the InfluxDB .env file. Since you’re mounting already established directories, InfluxDB shouldn’t need to go through the setup process. All of those environment variables are meant to trigger and automate the setup process. I think that’s why it keeps going into setup mode.

These instructions are really meant for standing up a new InfluxDB instance in a Docker container rather than moving an InfluxDB instance from the host machine into a container.

Without env… Nah, it just starts a clean version without using anything I loaded. No luck yet.

@roflas volumes in a compose file creates named volumes, but in your case, you might try specifying bind mount in your compose file to mount your existing fs directories into the container directories.

Alternatively, if you want to use named volumes, you could use the Docker CLI to create them for your existing fs directories and then use them in your compose file.

Thanks for help. I ended up just setting the system from scratch and restoring the backup. It is now fine although it is still unclear, why I was not able to mount it :slight_smile:

hi @roflas can you tell me what you did for “starting system from scratch” exactly? I’m facing the same issue and I already tried deleting the volumes.

Hey, I just configured basic installation with basic settings (in docker compose file), but later I just restored full backup of my previous DB. Full backup restores everything including tokens etc. So basically you will have the same thing you had before. This way I did not have to worry about using old influx data folders and attaching them to docker volumes, but I “made” good volumes after restoring backup.

Hope that helps.

Thanks a lot @roflas you made our day. I started a plain container without any env set, just like you and went ahead to delete the bolt file in /var/lib/influxdbv2/data/influxd.bolt. And later did docker compose to my original file that has env vars. And it worked