<i id='3ByOr'><tr id='3ByOr'><dt id='3ByOr'><q id='3ByOr'><span id='3ByOr'><b id='3ByOr'><form id='3ByOr'><ins id='3ByOr'></ins><ul id='3ByOr'></ul><sub id='3ByOr'></sub></form><legend id='3ByOr'></legend><bdo id='3ByOr'><pre id='3ByOr'><center id='3ByOr'></center></pre></bdo></b><th id='3ByOr'></th></span></q></dt></tr></i><div id='3ByOr'><tfoot id='3ByOr'></tfoot><dl id='3ByOr'><fieldset id='3ByOr'></fieldset></dl></div>

    <small id='3ByOr'></small><noframes id='3ByOr'>

      <legend id='3ByOr'><style id='3ByOr'><dir id='3ByOr'><q id='3ByOr'></q></dir></style></legend>
    1. <tfoot id='3ByOr'></tfoot>
        <bdo id='3ByOr'></bdo><ul id='3ByOr'></ul>

      在 ASP.NET Core 中构建 docker:“没有这样的文件或目录";错误

      时间:2023-09-17

        1. <small id='KMy4l'></small><noframes id='KMy4l'>

            <tfoot id='KMy4l'></tfoot>
            <i id='KMy4l'><tr id='KMy4l'><dt id='KMy4l'><q id='KMy4l'><span id='KMy4l'><b id='KMy4l'><form id='KMy4l'><ins id='KMy4l'></ins><ul id='KMy4l'></ul><sub id='KMy4l'></sub></form><legend id='KMy4l'></legend><bdo id='KMy4l'><pre id='KMy4l'><center id='KMy4l'></center></pre></bdo></b><th id='KMy4l'></th></span></q></dt></tr></i><div id='KMy4l'><tfoot id='KMy4l'></tfoot><dl id='KMy4l'><fieldset id='KMy4l'></fieldset></dl></div>

          • <legend id='KMy4l'><style id='KMy4l'><dir id='KMy4l'><q id='KMy4l'></q></dir></style></legend>

              <tbody id='KMy4l'></tbody>

            • <bdo id='KMy4l'></bdo><ul id='KMy4l'></ul>
                本文介绍了在 ASP.NET Core 中构建 docker:“没有这样的文件或目录";错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在构建 docker 时遇到错误.

                I'm getting an error when I build my docker.

                Sending build context to Docker daemon 3.584 kB
                Step 1/8 : FROM microsoft/aspnetcore:1.1
                 ---> 2628aaa7b8cf
                Step 2/8 : ENV ASPNETCORE_URLS "http://*:5000"
                 ---> Using cache
                 ---> 5dffde204fef
                Step 3/8 : ENV ASPNETCORE_ENVIRONMENT "Development"
                 ---> Using cache
                 ---> 3064358bc0eb
                Step 4/8 : ARG source
                 ---> Using cache
                 ---> 4159d0eb78c0
                Step 5/8 : WORKDIR /app
                 ---> Using cache
                 ---> 61a394c84304
                Step 6/8 : EXPOSE 5000
                 ---> Using cache
                 ---> c7c2309f7085
                Step 7/8 : COPY ${source:-obj/Docker/publish} .
                lstat obj/Docker/publish: no such file or directory
                

                这是我的 Dockerfile.

                Here's my Dockerfile.

                FROM microsoft/aspnetcore:1.1
                ENV ASPNETCORE_URLS="http://*:5000"
                ENV ASPNETCORE_ENVIRONMENT="Development"
                ARG source
                WORKDIR /app
                EXPOSE 5000
                COPY ${source:-obj/Docker/publish} .
                ENTRYPOINT ["dotnet", "ProjectTestApi.dll"
                

                然后我运行一个命令:

                $ docker build -t my-docker-image-test .
                

                你有什么问题吗?

                推荐答案

                发生这种情况是因为您没有发布解决方案.错误消息一目了然:

                no such file or directory
                

                默认情况下,当您向 ASP.NET Core Visual Studio 2017 项目添加 Docker 支持 时,它会创建一堆 docker-compose.yml 文件,其中一个它们是处理构建过程的 docker-compose.ci.build.yml.然后,当您通过 Visual Studio 构建项目时,会执行完整的 docker-compose 管道.

                By default, when you add Docker support to you ASP.NET Core Visual Studio 2017 project, it creates a bunch of docker-compose.yml files, one of them is docker-compose.ci.build.yml which handles the build process. Then, when you build the project through Visual Studio, full docker-compose pipeline is executed.

                docker-compose.ci.build.yml的内容,与此类似(显然取决于自定义配置和项目名称):

                The contents of docker-compose.ci.build.yml, are similiar to this (it depends on custom config and project names obviously):

                version: '2'
                
                services:
                  ci-build:
                    image: microsoft/aspnetcore-build:1.0-1.1
                    volumes:
                      - .:/src
                    working_dir: /src
                    command: /bin/bash -c "dotnet restore ./SolutionName.sln && dotnet publish ./SolutionName.sln -c Release -o ./obj/Docker/publish"
                

                正如您在最后一行看到的,调用了一个 dotnet publish 命令,它实际上构建了 &发布您的项目.

                As you can see in the last line, there is a dotnet publish command invoked, which actually builds & publishes your project.

                所以您的问题的解决方案,将只是在调用 docker 之前构建项目:

                So the solution for your issue, will be just building the project before calling docker:

                dotnet publish ./SolutionName.sln -c Release -o ./obj/Docker/publish
                docker build -t my-docker-image-test .
                

                这篇关于在 ASP.NET Core 中构建 docker:“没有这样的文件或目录";错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:复制 ..用于 ASP.NET 的 Dockerfile 中的命令 下一篇:无法加载共享库“libgdiplus"- Docker [带有 Aspose API 的 .NET 应用程序]

                相关文章

              1. <small id='6KZ5b'></small><noframes id='6KZ5b'>

                1. <i id='6KZ5b'><tr id='6KZ5b'><dt id='6KZ5b'><q id='6KZ5b'><span id='6KZ5b'><b id='6KZ5b'><form id='6KZ5b'><ins id='6KZ5b'></ins><ul id='6KZ5b'></ul><sub id='6KZ5b'></sub></form><legend id='6KZ5b'></legend><bdo id='6KZ5b'><pre id='6KZ5b'><center id='6KZ5b'></center></pre></bdo></b><th id='6KZ5b'></th></span></q></dt></tr></i><div id='6KZ5b'><tfoot id='6KZ5b'></tfoot><dl id='6KZ5b'><fieldset id='6KZ5b'></fieldset></dl></div>

                2. <legend id='6KZ5b'><style id='6KZ5b'><dir id='6KZ5b'><q id='6KZ5b'></q></dir></style></legend>

                    <bdo id='6KZ5b'></bdo><ul id='6KZ5b'></ul>

                  1. <tfoot id='6KZ5b'></tfoot>