我有一个dockerized ASP.net core 2.1应用程序,根据其运行的环境,它使用不同的appsettings.json。开发,生产,预览我如何查看应用程序在Docker容器中正在使用的当前appsetting.json?我需要这样做,以确保它以给定环境的正确设置运行。
答案 0 :(得分:0)
您可以使用docker run命令传递环境变量。
Path path = Paths.get("src/main/resources", "data.txt");
try (Stream<String> lines = Files.lines(path)) {
List<String> strings = lines.flatMap(l -> Arrays.stream(l.split(","))).map(String::trim)
.collect(Collectors.toCollection(LinkedList::new));
}
此外,可以从这样的配置中评估此变量,
docker run -it -e ASPNETCORE_ENVIRONMENT='Development' sample