Does visual studio debug start project differently from docker-compose us?

My project is compose of multiple ASP.NET services all orchestrated using docker-compose. I have been debugging and testing my project using visual studio. However, when I started to test my project without Visual studio by calling docker-compose up from PowerShell, the project build fails with the following error:

PS project_folder> docker-compose up
Starting my_service_db ... done                                                                                                                                                      Starting my_service_container ... done                                                                                                                                               Attaching to my_service_db, my_service_container
my_service_container |   It was not possible to find any installed .NET Core SDKs
my_service_container |   Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
my_service_container |       https://aka.ms/dotnet-download
my_service_container exited with code 145

That is because the base image does not have SDK installed, but as you see in the docker file that is not necessary since the builds are “copied” to the container:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /src
COPY ["MyService/MyService.csproj", "MyService/"]
RUN dotnet restore "MyService/MyService.csproj"
COPY . .
WORKDIR "/src/MyService/"
RUN dotnet build "MyService.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "MyService.csproj" -c Release -o /app

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

and docker-compose.yml is defined as the following:

version: '3.4'

services:

  sql.data:
    container_name: my_service_db
    image: microsoft/mssql-server-linux:2017-latest

  my_service:
    container_name: my_service_container
    image: ${DOCKER_REGISTRY-}my_service
    build:
      context: .
      dockerfile: MyService/Dockerfile
    depends_on:
      - sql.data

Hence, given that I can use the same files from Visual Studio and debug the application, not sure why it fails when called from PowerShell. It seems to me that the docker-compose up is either not calling or failing to properly use the Dockerfile, though not sure why? any thoughts?

Source: StackOverflow