【发布时间】:2019-11-21 15:41:04
【问题描述】:
我的 Dockerfile 是这个
FROM mcr.microsoft.com/dotnet/core/runtime:3.0
COPY publish/ app/
RUN mkdir -p /in
RUN mkdir -p /tmp
ENTRYPOINT ["dotnet", "app/Watcher.dll"]
我用这个命令构建图像
docker build -t watcher/sl_user_test:1.1 .
所以,我的 docker-compose 是这样的
watcher.sl_user_test:
image: watcher/sl_user_test:1.1
container_name: watcher_sl_user_test
build: .
restart: always
volumes:
- /var/storage/in:/in:z
- /var/storage/tmp:/tmp:z
在我的 dotnet 核心应用程序中,我在 /in 文件夹中获得了一个文件,然后将其移动到 /tmp/aaa 代码是这样的
string destination = $"/tmp/{Guid.NewGuid()}/git.zip";
new FileInfo(destination).Directory.Create();
File.Move("/in/git.zip", destination, true);
问题是这个命令复制文件并没有移动它,为什么? 如果我进入容器内部,我可以从 bash 执行 mv 并且它可以工作
【问题讨论】:
-
你可以对原始文件使用 File.Delete 吗? File.GetAttributes 返回什么?同一个程序可以读取移动文件的源吗?
-
File.Delete 作品
-
File.GetAttributes 说“正常”