【发布时间】:2019-07-29 03:27:10
【问题描述】:
我有一个关注Dockerfile来创建一个.NET Core 2.1 APP:
FROM microsoft/dotnet:2.1.402-sdk AS builder
WORKDIR /app
# copy csproj and restore as distinct layers
COPY . .
RUN dotnet restore ./myproject.sln
# copy everything else and build
COPY . .
RUN dotnet publish ./myproject/myproject.csproj -c Release -o /app/out
# build runtime image
FROM microsoft/dotnet:2.1.4-aspnetcore-runtime
WORKDIR /app
COPY --from=builder /app/out ./
ENV ASPNETCORE_ENVIRONMENT Production
ENTRYPOINT ["dotnet", "myproject.dll"]
我创建了 Docker 映像,并且可以毫无问题地实例化容器。当我尝试在这个容器和另一个容器之间共享数据时,我会创建以下 docker-compose 文件:
version: "2"
services:
another_app:
restart: always
image: another_app:latest
container_name: another_app
ports:
- "4000"
volumes:
- shared-folder:/dist
myproject_app:
restart: always
image: myproject:latest
container_name: myproject
volumes:
- shared-folder:/app
volumes:
shared-folder:
这样配置是行不通的。我收到该应用程序的奇怪 .NET 消息:
myproject_app | Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
myproject_app | http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
another_app| 0|another-a | Node Express server listening on http://localhost:4000
现在我发现当我在应用程序的根目录中定义卷时问题就消失了。例如,如果我这样做:
myproject_app:
restart: always
image: myproject:latest
container_name: myproject
volumes:
- shared-folder:/app/another-folder
然后就可以了。为什么不能在 .NET Core 应用程序的根级别挂载卷?为什么会出现该错误?
【问题讨论】:
-
同样的问题...
-
也看到了同样的问题。努力在网上找到任何东西来解释它。如果我确实让它在没有此问题的情况下运行,则该文件夹不会像我期望的那样用于应用程序文件
标签: docker .net-core docker-compose asp.net-core-2.1