Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

615
Vistas
ASP.NET Core 3.0 Docker Container port mapping fails

I am trying to get a brand new ASP.NET core MVC web application running from within a Docker container on my windows 10 machine.

I'm no docker expert but the port doesn't seem to get bound on the host. I get a response from within the container, but not from the host. The 2.2 sample works fine for me.

dotnet --version
3.0.100-preview6-012264

Steps to reproduce:

mkdir aspnetcore3_test
cd .\aspnetcore3_test\

mkdir aspnetapp
cd .\aspnetapp\

dotnet new mvc

cd ..
dotnet new sln

dotnet sln "aspnetcore3_test.sln" add "aspnetapp/aspnetapp.csproj"

Create a docker file with the following content:

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore ./aspnetapp/*.csproj

# copy everything else and build app
COPY aspnetapp/ ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
EXPOSE 80
ENTRYPOINT ["dotnet", "aspnetapp.dll"]

Then do the docker bits:

docker build -t dockertest .
docker run --rm -it --name=dockertest dockertest:latest -p 80:80

Docker run outputs the following:

warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {5b22d641-4632-4440-8f7d-8ad9b5e48098} may be persisted to storage in unencrypted form.
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://[::]:80
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app

With the container running Firefox says that it was unable to connect and docker port dockertest comes up empty

docker exec -i -t dockertest curl localhost spits out the template MVC app HTML

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

By adding the -p 80:80 after the name of the image, you're actually passing -p 80:80 as the args for the image executable, rather than as an arg for docker itself. The solution is to move that to before the image name:

docker run --rm -it --name=dockertest -p 80:80 dockertest:latest 
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda