简体   繁体   English

Docker和VS Mac

[英]Docker and VS Mac

Following the instructions on Docker's page I created a very simple Dockerfile that looks like this: 按照Docker页面上的说明,我创建了一个非常简单的Dockerfile,如下所示:

 FROM microsoft/dotnet:sdk AS build-env
 WORKDIR /app

 # Copy csproj and restore as distinct layers
 COPY *.csproj ./
 RUN dotnet restore

 # Copy everything else and build
 COPY . ./
 RUN dotnet publish -c Release -o out

 # Build runtime image
 FROM microsoft/dotnet:aspnetcore-runtime
 WORKDIR /app
 COPY --from=build-env /app/out .
 ENTRYPOINT ["dotnet", "dockertest.dll"]

This is literally a copy of the sample on Docker's site just changed the application name. 这实际上是Docker 网站上的示例副本,只是更改了应用程序名称。

I used Visual Studio for Mac to create a very simple ASP.Net application (actually, just the default app with a tiny HTML file added in). 我使用Visual Studio for Mac创建了一个非常简单的ASP.Net应用程序(实际上只是添加了一个很小的HTML文件的默认应用程序)。

When I first ran docker build -t dockertest . 当我第一次运行docker build -t dockertest . the line with dotnet publish failed. dotnet publish失败。 I then ran the dotnet publish manually and got past that. 然后,我手动运行了dotnet publish ,并dotnet publish了这个dotnet publish

It now fails on the copy: 现在,它在副本上失败:

Step 9/10 : COPY --from=build-env /app/out . 步骤9/10:复制--from = build-env / app / out。

 COPY failed: stat /var/lib/docker/overlay2/1484306cebf1def83638270757e70a8cf874fb5a167f39e5bfaae92a47cc071c/merged/app/out: no such file or directory

What's going on? 这是怎么回事?

So did you run dotnet publish inside the container or on the host machine? 那么,您是在容器内还是在主机上运行dotnet publish The Docker file is trying to run those commands inside the container, so running those on the host will not fix the issue. Docker文件正在尝试在容器内运行这些命令,因此在主机上运行这些命令将无法解决问题。

Have you tried to right click your project and "Add Docker Support" to your app in VS for Mac? 您是否尝试过右键单击您的项目,然后在VS for Mac中将“添加Docker支持”添加到您的应用程序中? It should generate a docker file and then you can run/debug your app inside the container from within VS. 它应该会生成一个docker文件,然后您可以从VS内部在容器内运行/调试应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM