My task's status is RUNNING and I can see the image on EC2 instance with docker ps
. But when I try to access the public IP and port the browser says that nothing was found. I've alredy set a security group rule to allow access to all TCP ports. What else can I do?
Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 5000
ENV PERSONAPI_ConnectionStrings__Database="[db connection string]"
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY [".", "personApi/"]
RUN dotnet restore "personApi/personApi.csproj"
RUN dotnet build "personApi/personApi.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "personApi/personApi.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "personApi.dll"]
Task ports:
Docker on EC2 instance
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8277d3be6a74 public.ecr.aws/z0o4m5x8/padrao:latest "dotnet personApi.dll" 2 minutes ago Up 2 minutes 0.0.0.0:32769->80/tcp, 0.0.0.0:32768->5000/tcp ecs-api-contato-2-api-contato-aeeefe81b1c8e7b75700
I finally figured out what was wrong. After some research I discovered that by default swagger only works in development mode, that's why I accessed when executed from Visual Studio but I couldn't access after publish.
So I changed this configuration and published again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.