{"id":20699637,"url":"https://github.com/hyeonsangjeon/springboot-properties-docker","last_synced_at":"2025-10-08T12:59:55.721Z","repository":{"id":100493082,"uuid":"189127698","full_name":"hyeonsangjeon/springboot-properties-docker","owner":"hyeonsangjeon","description":"How to use springboot properties in docker or docker-compose","archived":false,"fork":false,"pushed_at":"2019-06-03T05:23:38.000Z","size":8,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-22T22:28:29.204Z","etag":null,"topics":["docker-spring-boot-properties","properties","spring","spring-boot","spring-properties"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyeonsangjeon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-29T01:20:26.000Z","updated_at":"2024-09-30T18:42:16.000Z","dependencies_parsed_at":"2023-05-15T09:00:11.340Z","dependency_job_id":null,"html_url":"https://github.com/hyeonsangjeon/springboot-properties-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hyeonsangjeon/springboot-properties-docker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyeonsangjeon%2Fspringboot-properties-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyeonsangjeon%2Fspringboot-properties-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyeonsangjeon%2Fspringboot-properties-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyeonsangjeon%2Fspringboot-properties-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyeonsangjeon","download_url":"https://codeload.github.com/hyeonsangjeon/springboot-properties-docker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyeonsangjeon%2Fspringboot-properties-docker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278948023,"owners_count":26073748,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker-spring-boot-properties","properties","spring","spring-boot","spring-properties"],"created_at":"2024-11-17T00:31:12.590Z","updated_at":"2025-10-08T12:59:55.673Z","avatar_url":"https://github.com/hyeonsangjeon.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# springboot-properties-docker\nThis example shows how to use springboot properties in docker or docker-compose\n\nIn spring boot, variable processing priority is given according to the position of the property variable. \n\n\n##### The rest url that validates the properties variable looks like this:\n\n```shell\nhttp://localhost:8080/dynamicvalue\n---\ncurl -GET http://localhost:8080/dynamicvalue\n```\n\n## How to use\n\n1.maven build package jar\n```shell\nmvn clean package -DskipTest\n```\n\n2.CASE[1]: Run application and check variable 'dynamic.value' in application.properties[1]\n\n```shell\njava -jar ./target/springboot-properties-docker-0.0.1.jar\n\n```\n* result : helloworld\n\n3.CASE[2]:Add the dynamic.value variable to the OS environment variable and run this application.[2]\n```shell\n\u003e env dynamic.value=this_is_os_variable bash\n\u003e java -jar ./target/springboot-properties-docker-0.0.1.jar \n```\n* result : this_is_os_variable\n\n4.CASE[3]:Add a variable to the command line when jar file excution\n```shell\n\u003e java -jar ./target/springboot-properties-docker-0.0.1.jar --dynamic.value=commandline_variable \n```\n\n* result : commandline_variable\n\n## In Docker image Configuration\nIn this Dockerfile, \nThis image extends centos7 and jdk1.8 and container has its own environment.\nIt would be enough to declare what you want to override as environment properties and Spring Boot will fetch them, since environment variables take precedence over the yml files.\n\n##### 1.Docker build app \n \n```shell\n\u003e docker build -t test/test . \n```\n\n##### 2.Docker run app in command\n\n```shell\n\u003e docker run -rm -p8080:8080 -e dynamic.value=this_is_docker_os_variable test/test \n```\n* result : this_is_docker_os_variable\n\n##### 3.Docker-compose sample\n```shell\n\u003e docker-compose -f ./docker-compose.yml up \n\n\n---\n# after test\n\u003e docker-compose stop\n\u003e docker-cmpose rm\n```\n* result : this_is_docker_os_variable\n\nHere you have an example of how I launch a simple app environment with docker compose. As you see, I declare the 'dynamic.value' property here as an environment variable, so it overrides whatever you've got inside jar application.properties file.\n```yaml\n    environment:\n      dynamic.value : this_is_docker_os_variable\n```\n\n\n\n#### The environment variable dot(.) may not be override depending on the Springboot version. \nUse underscore(_) instead of dot(.) in this case. Springboot will automatically convert the underscore(dynamic_value) to the dot(dynamic.value) with Springboot Relaxed Binding.\n\n```yaml\n    environment:\n      dynamic_value : this_is_docker_os_variable_unser_score\n```\n\n### The priority rank according to the properties position is as follows.\n```text\n1. 'Spring-boot-dev-tools.properties' file in the user's home directory\n2. @TestPropertySource\n3. The properties attribute of the @SpringBootTest annotation\n4. Command line arguments                           \u003c-------[3]\n5. Properties in SPRING_APPLICATION_JSON (environment variable or system property)\n6. ServletConfig Parameters\n7. ServletContext parameter\n8. java:comp/env JNDI attribute\n9. System.getProperties () Java System Properties\n10. OS environment variables                        \u003c-------[2]\n11. RandomValuePropertySource\n12. Application properties for a specific profile outside the JAR\n13. Application properties for a specific profile in the JAR\n14. Application properties outside the JAR\n15. Application properties in the JAR                \u003c------[1]\n16. @PropertySource\n17. Default property (SpringApplication.setDefaultProperties)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyeonsangjeon%2Fspringboot-properties-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyeonsangjeon%2Fspringboot-properties-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyeonsangjeon%2Fspringboot-properties-docker/lists"}