Best practice of stopping InfluxDB inside a docker container without stopping the container

I need to create a new operator token for my instance running in a docker container since I don’t have one. Following this conversation on GitHub, I got to the point, where I entered
influxd recovery auth create-operator --org xxx --username yyy --bolt-path /var/lib/influxdb2/influxd.bolt
inside the container but I got the Error
Error: unable to open boltdb file unable to open boltdb file timeout
which is the result of running this command while influxDB is still running. Now, I have to stop the influxd process, run the command above and restart the InfluxDB Server. What is the best practice of doing so? I could just kill the influxd process, but I thought that there has to be a better option.
The ìnfluxd CLI command has no subcommand stop, so how can I do this elegantly?

In general, you can send a CTRL+C (SIGINT) to stop the process and it will do the necessary cleanup before shutting down. That will also shut the container down.

If you want to run commands against the DB (as you indicated by wanting to run influxd recovery), the best was it to run the same image with all the same flags, but with /bin/bash at the end. This will drop you into a shell that you can use to execute any commands you need to. The next time you start the container, start it without /bin/bash at the end and it should start you back up into influxdb

Thanks for your answer. I am running the influxDB instance with an grafana instance via a docker compose file, but I replicated the mounted volumes and environment variables in a docker run command, stopped the original influx container and started the new version with the /bin/bash command at the end to override the original entrypoint. I tried the influxd recovery command again, but I got the following error:

2023-02-07T08:15:20.629657Z	info	Resources opened	{"log_id": "0frjwtCl000", "system": "bolt-kvstore", "path": "/var/lib/influxdb/influxd.bolt"}
Error: bucket "authorizationsv1": bucket not found
See 'influxd -h' for help

It seems like the command found the database and opened it, but it still could not find the “authorizationsv1” bucket. Is there another way of fixing this issue?

In the GitHub Thread, you mentioned that it is possible to log into the CLI with the user that created the Database, which gives you operator token permissions. I searched for a “login” subcommand for the influx and influxd commands but didn’t found anything in the docs. Could you link me a documentation page on how to log in using the CLI?

For the first part, my guess would be something is wrong with the pathing of your volume and the bolt file is not actually there. Looks like you have /var/lib/influxdb/influxd.bolt and you might want /var/lib/influxdb2/influxd.bolt? You can also verify on your local machine if that bucket actually exists by using the boltdbweb tool to inspect the file. If that bucket is not there, something has gone wrong writing the file, and if it is there then it may be a recovery bug.

The Release notes have a bit of an explanation and a link out to the rest of the docs that may help explain the login capability influx CLI release notes | InfluxDB OSS 2.6 Documentation

Thanks for your advise. The path was correct, I just copied the command from the GitHub Conversation, which had the influxdb2 folder. I also verified the existence of the bucket with the Tool you linked on my local machine. At that moment I wanted to try the influxd recovery command locally with the copy of the .bolt db and this time, it worked! I’m not sure why the command failed on my VM, but maybe some Docker magic prevented it from being accessed properly. I transferred the modified file over to the VM and restarted my Docker container. The new operator token is being shown by the Influx UI.