How docker specifies parameter variables externally
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.