Docker Community Forums

Share and learn in the Docker community.

Path based on ENV Variables

I was wondering if there was a way to do this.

given a .env file with

sensorName=foobar

Can i configure my service in docker compose to use the sensorName to define the path.

Example:

  example-collector:
    image: netsage/nfdump-collector:1.6.18
    command: nfcapd -T all -l /data -S 1 -w -z -p 9999
    ports:
      - "9999:9999/udp"
    restart: always
    volumes:
      - ./data/input_data/${sensorName}:/data

I’m sure that’s not the correct pattern, but it’d be a really great nice to have. Any thoughts?