Localhost not running when creating a container in backend

  Kiến thức lập trình

My project is a web app utilizing Angular and .NET. While creating the Dockerfile for the backend, building the image, and creating the container, everything progresses successfully. However, upon attempting to access the localhost, the message ‘This site can’t be reached’ is displayed.

This is my dockerfile for the backend:
`#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

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

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY [“./WebApplication3/ProjP2M.csproj”, “./WebApplication3/”]
RUN dotnet restore “WebApplication3/ProjP2M.csproj”
COPY . .
WORKDIR “/src/WebApplication3”
RUN dotnet build “ProjP2M.csproj” -c Release -o /app/build

FROM build AS publish
RUN dotnet publish “ProjP2M.csproj” -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY –from=publish /app/publish .
ENTRYPOINT [“dotnet”, “ProjP2M.dll”]`

and this is the command when creating the container after building the image:
docker run -d --name app4 -p 7006:80 -p 7005:443 application4

This is the error when running : https://localhost:7005/swagger/index.html :https://localhost:7005/swagger/index.html

LEAVE A COMMENT