在我的java应用程序中,我将环境变量读取为:
String inputPath = System.getProperty("INPUT_PATH");
然后我在 docker 容器中运行它:
docker run -it -e INPUT_PATH='/home/...data/input.txt' myapp:1.0.0
但是程序无法读取环境变量INPUT_PATH。
我在这里犯了什么错误?
使用
System.getenv()
访问环境变量。
String inputPath = System.getenv("INPUT_PATH");
参考 - https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#getenv--