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.
741 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Suresh Estharakula 310 Reputation points Microsoft External Staff
    2025-03-07T01:55:17.53+00:00

    Hi Binod Kumar,

    Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.

    Based on our understanding of your issue, we recommend that you refer to the following methods for troubleshooting:

    The "connection reset" error encountered while trying to access your Azure Container Instance may arise from multiple factors, including improper port configuration, network security settings, or application-related issues. It is crucial to examine the container logs, confirm that the correct ports are exposed, and ensure that your application is configured to listen on the designated IP address.

    • Check the logs for any errors or exceptions by using Azure CLI:
    az container logs --resource-group <YourResourceGroup> --name <YourContainerName>
    

    Ensure that the ports are correctly exposed to your application. When creating the container instance, specify the ports:

    az container create --resource-group <YourResourceGroup> --name <YourContainerName> --image <YourImage> --ports <PortNumber>
    
    • If the container instance is integrated within a Virtual Network (VNet), ensure that there are no network security group (NSG) rules or firewall configurations that may delay access to the container.
    • Ensure that the Network Security Group (NSG) linked to your container instance permits inbound traffic on the necessary ports. Modify the rules as needed within the Azure Portal.
    • Test the IP address with curl or telnet to verify if the container instance is responding or not.
    curl http://<container-ip>:<port>
    
    • Restart the container instance to resolve any issues:
    az container restart --resource-group <YourResourceGroup> --name <YourContainerName>
    

    If you found it helpful, could you kindly click the “Accept Answer and upvote” on the post.

    If you have any further queries, please let us know we are glad to help you.


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.