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: