I have a dockerized spring boot application with an application.yml containing the following property:

rest-template:
    connection-timeout: 1000
    read-timeout: 1000

Now let's say I want to update the connection timeout value when running the docker run command. I am aware that one of ways is to update the application.yml file:

rest-template:
    connection-timeout: ${REST_CONNECTION_TIMEOUT:1000}
    read-timeout: ${REST_READ_TIMEOUT:1000}

Then we can run the docker run command as follows:

docker container run -d --name test-service -e REST_CONNECTION_TIMOUT=5000 test-service-img

But say if I wanted to update this without having to use REST_CONNECTION_TIMOUT in the application.yml.

How would this property this map to the env variable in the docker command ?

1

There are 1 best solutions below

0
On

You can rely on the relaxed binding of Spring Boot - one of its features is to map environment variables to configuration properties.

In your case, you can use:

... -e RESTTEMPLATE_CONNECTIONTIMEOUT=5000 -e RESTTEMPLATE_READTIMEOUT=5000 ...