How to access INFLUXDB_ORG_ID in docker compose?

Hi,

I have a customized server which needs INFLUXDB_ORG_ID as an environmental variable. However, according to the document (https://hub.docker.com/_/influxdb/), INFLUXDB_ORG_ID is exported as environmental variable after creating its docker image. I wonder if there is a way to retrieve this value and feed it to another server?

influxdb:
    image: influxdb:latest
    container_name: influxdb
    restart: always
    ports:
      - "8086:8086"
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - influxdb-storage:/var/lib/influxdb2
      - influxdb-config:/etc/influxdb2
    environment:
      - DOCKER_INFLUXDB_INIT_MODE=setup
      - DOCKER_INFLUXDB_INIT_USERNAME=${INFLUXDB_INIT_USERNAME}
      - DOCKER_INFLUXDB_INIT_PASSWORD=${INFLUXDB_INIT_PASSWORD}
      - DOCKER_INFLUXDB_INIT_ORG=${INFLUXDB_INIT_ORG}
      - DOCKER_INFLUXDB_INIT_RETENTION=365d
      - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=${INFLUXDB_INIT_ADMIN_TOKEN}
      - INFLUXDB_HTTP_HTTPS_ENABLED=true
      - INFLUXDB_HTTP_HTTPS_CERTIFICATE=/etc/ssl/influxdb-selfsigned.crt
      - INFLUXDB_HTTP_HTTPS_PRIVATE_KEY=/etc/ssl/influxdb-selfsigned.key
data-manager:
    build: /data-manager
    container_name: data-manager
    depends_on:
      - influxdb
    ports:
      - "5000:5000"
    environment:
      - INFLUXDB_ORG_ID=

Hi, I realize this is belated, but you can use the container’s influx CLI to get the org ID:

docker exec -it influxdb2 influx org list

or

docker exec -it influxdb2 influx org list --json