Just use a Docker compose file and point your Spring project to the right file, like explained in the Spring DOCs :
spring.docker.compose.file=../my-compose.yml
Look up the InfluxDB docker image DOCs for the configuration you need. Minimal example:
services:
time-series-database:
# Change to your version of choice - https://hub.docker.com/_/influxdb/tags
image: influxdb:2.7-alpine
ports:
- 127.0.0.1:8086:8086
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=john-doe
- DOCKER_INFLUXDB_INIT_PASSWORD=my-super-secret-password
- DOCKER_INFLUXDB_INIT_ORG=acme-inc
- DOCKER_INFLUXDB_INIT_BUCKET=my-bucket
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=0YVmO2e179ymcr4AZoA9FOEAIZSdDmezA8yIuLnSL4ERowgKZGKWEKqZAR64BCVn1aC4tN6Jq7aVM0ldAMZJIQ==