Hello
New to InfluxDB2 here.
Here’s what I would like to do:
- Have a InfluxDB2 Docker container, built from a custom Dockerfile using the official image.
- Be able to start or restart it regardless or what the data volume contain, empty or not. It simply takes off where it was left, if applicable.
To do that, on any other container profile, I have (and want to have):
- A mount (bind/volume, whatever) between host computer and the data storage directory inside the container.
- A use of a Dockerfile with
COPY
instructions pushing whatever is needed inside.
And nothing else. This works for any technology out there (PostGreSQL, MySQL, MongoDB, etc.).
To use InfluxDB, I need (from my understanding):
- To create an account to access the web API (where is that stored? How to deploy that?)
- To create a token to access the web API (same question)
So my question is: HOW to achieve this automatically?
So far, when I start the containers for the first time, the DOCKER_INFLUXDB_INIT_MODE=setup
seems to be the way to go. But I’m not sure about that. When I let the container do so, it starts a new setup, regenerates everything, and changes the tokens, which is not what I need. When I do that, the VOLUME instruction inside the official image also auto-mounts the configuration, and restarting the container is impossible, as the official Docker Hub entrypoint.sh
uses set -euo pilefail
AND the command influx config
returns a non-0 exit status code, stopping the script, stopping the container on start.
Removing the DOCKER_INFLUXDB_INIT_MODE
and emptying the volume leads to a good container start… With no account, so it actually needs the setup. Is the setup the intended option to have containers being (re)created?
Does anyone know how to configure a Docker Compose file and a Dockerfile to achieve this? I want to achieve standalone, static configuration inside the containers with the paradigme mentioned above.
Which would mean (if I’m correct):
- Pushing versioned configuration (including tokens, credentials, etc.)
- Having a volume mounted for the data being inserted ONLY.
I do not want a volume for configuration, and I do not want to run commands on production, QA environments or else to start containers. I just want a Docker Compose, Dockerfile, and config assets that I need to have a permanently working container, that I can access the same way.
I do not want to manually recreate anything evertime I create/run new containers, of course. I just want to instanciate the containers with pre-made config that works, and the mount is handlede by Docker (if data on host, then it becomes the container data, otherwise, Docker will create the host mount directory).
EDIT: I found a possible solution.
- prepare the container locally
- grab the config, bolt and sqlite files and CP them to the git directory
- mount a volume ONLY to the
[data dir]/engine
directory - remove the
DOCKER_INFLUXDB_INIT_MODE=setup
variable from ENV
Seems like this would work.
Thanks!