skip to Main Content

We currently load ips from src/main/resources/application.properties as a Map<String, List>

server:
  config:
    ips:
      - 10.10.10.10
      - 10.10.10.11
      - 10.10.10.12
      - 10.10.10.13

If I have to pass this from the ENV for a docker container, how should I do it

2

Answers


  1. server:
      config:
        ips:
          - 10.10.10.10
          - 10.10.10.11
          - 10.10.10.12
          - 10.10.10.13
    

    Is equivalent to

    server:
      config:
        ips: ["10.10.10.10", "10.10.10.11", "10.10.10.12", "10.10.10.13"]
    

    It seems you are using spring… so perhaps you could do

    server:
      config:
        ips: [${SERVER_IPS}]
    

    Then set an environment variable

    SERVER_IPS="10.10.10.10","10.10.10.11","10.10.10.12","10.10.10.13"
    

    In this instance I don’t think you need the quotes (each value contains at least one non-numeric character, values don’t contain commas) so you can likely do

    SERVER_IPS=10.10.10.10,10.10.10.11,10.10.10.12,10.10.10.13
    
    Login or Signup to reply.
  2. I’d use a colon (or separator char of your preference) separated value list to send it in a single env variable and then just split it by separator on the receiver end.

    env:
      name: IP_LIST
      value: "10.10.10.10;10.10.10.11;10.10.10.12;10.10.10.13"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search