Getting connection reset while accessing azure container instance

Binod Kumar 20 Reputation points
2025-03-06T12:01:43.76+00:00

I have created one docker image using dot net core and successfully pushed the image in container registry. After that I have published the same image in container app and container instance. I am not getting any issue in container app, but getting "the connection was reset" while accessing container instance.

I have verified the ports as well. PFB my docker file

This stage is used when running from VS in fast mode (Default for Debug configuration)

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base

USER $APP_UID

WORKDIR /app

EXPOSE 8080

EXPOSE 8081

This stage is used to build the service project

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build

ARG BUILD_CONFIGURATION=Release

WORKDIR /src

COPY ["MyAPI/MyAPI.csproj", "MyAPI/"]

RUN dotnet restore "./MyAPI/MyAPI.csproj"

COPY . .

WORKDIR "/src/MyAPI"

RUN dotnet build "./MyAPI.csproj" -c $BUILD_CONFIGURATION -o /app/build

This stage is used to publish the service project to be copied to the final stage

FROM build AS publish

ARG BUILD_CONFIGURATION=Release

RUN dotnet publish "./MyAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)

FROM base AS final

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "MyAPI.dll"]

And while configuring network I have already selected network type as public and given the ports 8080 and 8081.

Still it is not working, Please assist.

Thanks in advance.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
751 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Suresh Estharakula 400 Reputation points Microsoft External Staff
    2025-03-13T16:08:04.1666667+00:00

    Hi Binod Kumar,

    • Make sure the Docker container is correctly mapped to your local computer and is exposing the appropriate port. For instance, you must ensure that your application is mapped to a local port if it is operating on port 80 within the container,
        docker run -p 8080:80 your_image_name
      
    • Verify that your Dockerfile is configured to expose the appropriate port. For instance, if your application operates on port 80, it is essential that the Dockerfile specifies this port.
        Expose 80
      
    • The connection may be blocked by firewall or security software if you are using Docker on Windows or macOS. Make that the port you're attempting to utilize (such as 8080) is open to traffic on your firewall.
    • The application running within the container may fail to connect to the appropriate network interface, potentially restricting its binding to localhost only. It is essential to ensure that your application is configured to bind to 0.0.0.0, indicating that it listens on all available network interfaces.
    • If the application is running but you're not able to browse to it, it might be helpful to check the logs to see if there are any errors preventing it from serving content.
        docker logs <container_id>
      
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.