c++ - C++ 应用程序不读取 json 文件 - Docker 容器
问题描述
我编写了执行计算的 ac++ 程序。值应该从 JSON 文件中读取,然后存储在变量中。我现在已经在 Docker 容器(alpine)中启动了这个应用程序。在应用程序中,除了从 JSON 文件中读取数据外,一切正常。在容器之外,程序运行没有问题。
这会是什么?Docker 是否需要为 .JSON 文件指定不同的目录?或者为什么会这样?
C++:
// filestream variable file
std::fstream file;
std::string word, filename;
std::string stringA= "";
// filename of the file
filename = "TestX.json";
// opening file
file.open(filename.c_str());
// extracting words form the file
while (file >> word)
{
if((word.find("ABC",0))!=-1){
file >> word;
stringA= word;
}
if((word.find("CDE",0))!=-1){
file >> word;
stringB = word;
}
if((word.find("EFG",0))!=-1){
file >> word;
stringC = word;
}
if((word.find("GHI",0))!=-1){
file >> word;
stringD = word;
}
}
码头工人命令:
docker run -it -p 8080:1234 test
解决方案
推荐阅读
- docker - 带有 Docker 的 Serilog Seq Sink 未捕获事件
- elasticsearch - 需要帮助才能在字段上正确执行通配符搜索
- java - 寻找最高考试范围的问题
- azure - Azure Datalake 本地或混合堆栈
- python - Python:TypeError:只能在第 9 行分配一个可迭代对象
- python - 为什么 checkpoint 中保存的参数与融合模型中保存的参数不同?
- linux - 一次运行两个子进程的 Shell 脚本
- python - 我们可以根据文本匹配合并两个数据框吗?
- arrays - 满足约束的数组中的四倍
- sockets - Netty Detect传入请求是protobuf类型