locked
WEB API and Docker host issue RRS feed

  • Question

  • User-2048090339 posted

    Dear all,

    I have a simple web api project for which I need to host it under Docker image.

    For that I have added the following docker file to my root project :

    FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-nanoserver-1709 AS base
    WORKDIR /app
    EXPOSE 80
    
    FROM mcr.microsoft.com/dotnet/core/sdk:2.2-nanoserver-1709 AS build
    WORKDIR /src
    COPY ["BooksApi/BooksApi.csproj", "BooksApi/"]
    RUN dotnet restore "BooksApi/BooksApi.csproj"
    COPY . .
    WORKDIR "/src/BooksApi"
    RUN dotnet build "BooksApi.csproj" -c Release -o /app
    
    FROM build AS publish
    RUN dotnet publish "BooksApi.csproj" -c Release -o /app
    
    FROM base AS final
    WORKDIR /app
    COPY --from=publish /app .
    ENTRYPOINT ["dotnet", "BooksApi.dll"]

    If I compile and run the app from visual studio , docker file gets compile and runn properly and I can hit my web site api.

    Then I have try to compile and run doker image outide visual studio using docker command as explain in different post.
    For that I open a powershell command and then run  the follwing command from the root of my project :

    docker build -t myimage .

    by doing so I get a failure error as desribed below :

    Docker error

    Any idea what can be wrong ?

    regards

    Wednesday, August 14, 2019 8:03 AM

Answers

  • User-2048090339 posted

    Find it out , it was one level down too much in the path level

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 14, 2019 9:09 AM