Skip to content

Need help environment variables not working inside docker when running with compose #778

@Raimond56

Description

@Raimond56

Hello,

I need some help how to get this working.

I am trying to use environment variables inside docker compose and file loader for targets.

This is what I am running with docker compose:

  gnmic:
    image: harbor.srv.rmv/ghcr/openconfig/gnmic:latest
    container_name: gnmic
    volumes:
      - ./gnmic/gnmic.yaml:/gnmic.yaml
      - ./gnmic/targets.yaml:/targets.yaml
      - ./gnmic/certs:/certs:ro
      - ./gnmic:/gnmic:rw
    env_file:
      - ./.env
    command: "subscribe --config gnmic.yaml"
    networks:
      - monitoring-network
    ports:
      - 9804:9804

Inside .env file I have defined 1 variable
SRX_PASS=testpw

When I run "sudo docker exec gnmic env"
It does sees the env variable.

Inside gnmic.conf I have this loader conf

loader:
  type: file
  expand-env: true
  path: targets.yaml
  interval: 60s

Inside targets file I have this

srx-firewall:
  address: 10.10.10.5:50051
  subscriptions:
    - junos
  password: ${SRX_PASS}

This setup works without docker. But when running this docker compose the authentication fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions