未安装Docker组成的卷

时间:2018-10-17 13:09:56

标签: docker visual-studio-2017 docker-compose

我有一个简单的ASP.net Core项目,我使用docker-compose在docker容器中运行。我试图挂载主机目录以保存一些文件,例如日志文件。

我的Dockerfile看起来像这样:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 55498
EXPOSE 44396

FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY calibration-upload-server/calibration-upload-server.csproj calibration-upload-server/
RUN dotnet restore calibration-upload-server/calibration-upload-server.csproj
COPY . .
WORKDIR /src/calibration-upload-server
RUN dotnet build calibration-upload-server.csproj -c Release -o /app

FROM build AS publish
RUN dotnet publish calibration-upload-server.csproj -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "calibration-upload-server.dll"]

我的docker-compose文件:

version: '3.4'

services:
  calibration-upload-server:
image: ${DOCKER_REGISTRY}calibration-upload-server
build:
  context: .
  dockerfile: calibration-upload-server/Dockerfile
volumes:
- C:/Uploads/logs:/logs

在Visual Studio中构建解决方案时,docker compose似乎能够解析文件,并且卷组如下所示:

volumes:
- C:\Uploads\logs:/logs:rw
- C:\Users\UserName\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro
- C:\Users\UserName\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro

因此,似乎文件已正确解析(其他两个卷来自替代文件)。但是,当我运行解决方案时,docker run的运行没有此卷:

docker run -dt -v "C:\Users\UserName\vsdbg\vs2017u5:/remote_debugger:rw" -v "C:\Repos\calibration-upload-server\calibration-upload-server:/app" -v "C:\Users\UserName\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro" -v "C:\Users\UserName\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro" -v "C:\Users\UserName\.nuget\packages\:/root/.nuget/fallbackpackages2" -v "C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages" -e "DOTNET_USE_POLLING_FILE_WATCHER=1" -e "ASPNETCORE_ENVIRONMENT=Development" -e "ASPNETCORE_URLS=https://+:443;http://+:80" -e "ASPNETCORE_HTTPS_PORT=44396" -e "NUGET_PACKAGES=/root/.nuget/fallbackpackages2" -e "NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages;/root/.nuget/fallbackpackages2" -p 55498:80 -p 44396:443 --entrypoint tail calibrationuploadserver:dev -f /dev/null

最令人沮丧的部分是,此工作得很好,直到我重命名解决方案和项目为止。我不知道这是否是破坏它的原因,但仍然如此。

在构建时可能还需要注意的另一件事是,我警告The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.

反正有找出错误的地方吗?

0 个答案:

没有答案