Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How docker specifies parameter variables externally

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how docker specifies parameter variables externally, which is introduced in great detail through the sample code, which has a certain reference and learning value for everyone's study or work. Friends who need it can refer to it.

Dockerfile:

FROM frolvlad/alpine-oraclejre8:slimVOLUME / tmpADD app.jar / app.jar#COPY agent/ / usr/local/skyagent/WORKDIR / optCOPY docker-entrypoint.sh .ENV AP_ENV=$AP_ENVEXPOSE 7015ENV JAVA_OPTS=$JAVA_OPTSENTRYPOINT ["sh", "- c", "java $JAVA_OPTS-Djava.security.egd=file:/dev/./urandom-jar / app.jar"]

Variable given in configuration: application.properties

Sea=$ {sea123} shan=$ {shan123}

For Test:

@ RestControllerpublic class WebController {@ Value ("${sea}") private String sea; @ Value ("${shan}") private String shan; @ GetMapping ("/ sea") public String test () {return sea+shan;}}

Run the image:

Sudo docker run-it-p 9999pur9999-e 'sea=sea_test'-e' shan=shan_test' testproperties004

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 240

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report