I have a WebApi created using .Net Core. I have a .dockerfile in the root of my solution:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.1-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.1-stretch AS build
WORKDIR /src
COPY ["Nuget.config", ""]
COPY ["Proyecto.WebApi/Proyecto.WebApi.csproj", "Proyecto.WebApi/"]
COPY ["Proyecto.Model/Proyecto.Model.csproj", "Proyecto.Model/"]
COPY ["Proyecto.Bl/Proyecto.Bl.csproj", "Proyecto.Bl/"]
RUN dotnet restore "Proyecto.WebApi/Proyecto.WebApi.csproj" --configfile "Nuget.config"
COPY . .
WORKDIR "/src/Proyecto.WebApi"
RUN dotnet build "Proyecto.WebApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Proyecto.WebApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Proyecto.WebApi.dll"]
I can build, run and push my Api without problem using those commands:
docker build -t dockerlocal .
docker run -d -p 8080:80 --name myapp dockerlocal
docker tag <image_id> docker.nexus.example.com/dockerlocal
docker push docker.nexus.example.com/dockerlocal
When I test my api from the browser http://localhost:8080/api/values, it works perfectly. Now I need, download the image from the repo and run the Api, so I execute:
docker pull docker.nexus.example.com/dockerlocal
docker run -d -p 9090:90 --name mynexusapp docker.nexus.example.com/dockerlocal
According the console, everything is working. But when I test the API http://localhost:9090/api/values I get in my browser: "localhost no envió ningún dato. ERR_EMPTY_RESPONSE"
What is the problem? Why I can't run my WebApi after docker pull comand.