docker run command not taking the –env variable placeholder value

  docker, java, microservices, spring-boot

I am trying to run a docker image with the below command :

docker run -p 5000:5000 shoppingms:latest --env shopping-service.configserverurl=http://shopping-config:8888/ --env shopping-service.eureka.url=http://shopping-eureka:4444/

I have set the host name in /etc/hosts file to point to the docker IP. However it is throwing UnknownHost error.

And when I am giving the IP address instead, then also it takes the default value from bootstrap.yaml, throwing the same error.

Bootstrap.yaml

    spring:
       cloud:
         config:
           uri: ${shopping-service.configserverurl:http://shopping-config:8888}
           fail-fast: true
           retry:
             maxAttempts: 20

However when I give the actual docker host IP in the placeholder above, it is running fine.

Working case :

uri: ${shopping-service.configserverurl:http://<Docker-Host>:8888}

Why it is not able to parse the actual placeholder IP value from the docker run command ?

Source: Docker Questions

LEAVE A COMMENT