docker 在外部指定参数变量
作者:互联网
Dockerfile:
FROM frolvlad/alpine-oraclejre8:slim VOLUME /tmp ADD app.jar /app.jar #COPY agent/ /usr/local/skyagent/ WORKDIR /opt COPY docker-entrypoint.sh . ENV AP_ENV=$AP_ENV EXPOSE 7015 ENV JAVA_OPTS=$JAVA_OPTS ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
配置中给与变量:application.properties
sea=${sea123} shan=${shan123}
用于Test:
@RestController public class WebController { @Value("${sea}") private String sea; @Value("${shan}") private String shan; @GetMapping("/sea") public String test() { return sea+shan; } }
运行镜像 :
sudo docker run -it -p 9999:9999 -e 'sea=sea_test' -e 'shan=shan_test' testproperties004
标签:变量,外部,app,jar,ENV,sea,docker,shan,String 来源: https://www.cnblogs.com/lshan/p/11419251.html