![](/img/trans.png)
[英]How to set JVM arguments when running mvn spring-boot:build-image command in Spring Boot 2.3.0 to generate a docker image?
[英]Spring boot with docker build mvn spring-boot:build-image with jvm parametes
我正在嘗試使用命令為我的 spring 啟動 docker 構建 docker 映像
mvn spring-boot:build-image
下面是我的 docker-compose.yml
version: '3.3'
services:
spring-boot-container:
ports:
- '7000:7000'
environment:
- SPRING_PROFILES_ACTIVE=${environment}
- JASYPT_ENCRYPTOR_PASSWORD=${JASYPT_ENCRYPTOR_PASSWORD}
- cloud_config_uri=${cloud_config_uri}
- "JAVA_OPTS=-Dspring.cloud.config.uri=http://localhost:8888"
image: 'artifactory.cloud.health.com/docker-all/spring_boot_app:latest'
restart: always
container_name: spring_boot_app
但是我的 spring 啟動應用程序沒有提供正確的配置文件,也沒有選擇 java _opts。
基本上在舊方法中,我創建 dockerfile,然后在我通過-Dspring.active.profiles
ENTRYPOINT
但是由於我們使用mvn spring-boot:build-image
我不知道我們如何傳遞這些入口點變量。
好的,終於解決了,它的語法問題。 以下編寫環境的方式有效!
environment:
- JAVA_OPTS=
-Dspring.profiles.active=${environment}
-Dspring.cloud.config.enabled=true
-Dspring.cloud.config.uri=${cloud_config_uri}
-Djasypt.encryptor.password=${JASYPT_ENCRYPTOR_PASSWORD}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.