docker下springboot的多環境配置

NemoHero發表於2020-12-09

 1、Dockerfile 構建檔案定義引數

FROM java:8
VOLUME ["/home/pdsstm/uploads/pdsfile"]
COPY pds-stm-management.jar /home/pds-stm/jar/pds-stm-management.jar
ENV CE=$CE
EXPOSE 31080
ENTRYPOINT [ "sh", "-c", "java  -Djava.security.egd=file:/dev/./urandom -jar /home/pds-stm/jar/pds-stm-management.jar --spring.profiles.active=$CE" ]

定義變數 CE

2、進入到 資料夾下構建映象

docker build -t pds-stm .

3、帶引數執行映象

docker run -d -p 38082:31080 --name pds-stm -e CE="test" -v /home/pds-stm/jar:/home/pds-stm/jar -v /home/pds-stm/logs:/logs  --restart=always pds-stm

 

相關文章