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

 

上一篇:贪心-放置雷达


下一篇:全球变暖——BFS+模拟