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}
user.namespace=${user_namespace:default-namespace} //如果未指定,则使用默认
用于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