question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All the APIs showing Offline while working on docker containers

See original GitHub issue

I have been working on this project for a while and started to deploy on docker containers, but having some issue while doing so, I hope you can give me some ideas about the problem. Docker compose build fine but does not render the pages as it should be. Following are my docker files setup :-

Formerly i have tried to apply docker file to all the projects but after having this problem I tried to start from a project rather than whole therefore, I have tried to recreate/reproduce the problem with a customer management project:-

Docker file CustomerManagement API

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
COPY ["src/CustomerManagement/CustomerAPI/CustomerAPI.csproj", "src/CustomerManagement/CustomerAPI/"]

COPY . .
WORKDIR "/src/src/CustomerManagement/CustomerAPI"
RUN dotnet build "CustomerAPI.csproj" -c Release -o /app
RUN dotnet restore -s https://api.nuget.org/v3/index.json -s https://www.myget.org/F/autoweb/api/v3/index.json


FROM build AS publish
RUN dotnet publish "CustomerAPI.csproj" -c Release -o /app

HEALTHCHECK --interval= --timeout= --retries=1 CMD curl --silient --fail http://localhost:5000/hc || exit 1

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "CustomerAPI.dll"]

Launch settings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:5000",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "index.html",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "CustomerAPI": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "index.html",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:5000"
    }
  }
}

Docker file Web:-

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
COPY ["src/WebManagement/Web/Web.csproj", "src/WebManagement/Web/"]

COPY . .
WORKDIR "/src/src/WebManagement/Web"
RUN dotnet build "Web.csproj" -c Release -o /app
RUN dotnet restore -s https://api.nuget.org/v3/index.json -s https://www.myget.org/F/autoweb/api/v3/index.json


FROM build AS publish
RUN dotnet publish "Web.csproj" -c Release -o /app

HEALTHCHECK --interval=30s --timeout=3s --retries=1 CMD curl --silent --fail http://localhost:7000/hc || exit 1


FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Web.dll"]

Launch settings.json

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:7000",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "http://localhost:7000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "http://localhost:7000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:7000"
    }
  }
}

Docker compose.yml file

version: '3.4'

services:

  logserver:
    image: datalust/seq:latest

  sqlserver:
    image: mcr.microsoft.com/mssql/server:2017-latest

  rabbitmq:
    image: rabbitmq:3-management-alpine

  customerapi:
    image: ${DOCKER_REGISTRY-}customerapi
    build:
      context: .
      dockerfile: src/CustomerManagement/CustomerAPI/Dockerfile
    depends_on:
      - sqlserver
      - rabbitmq

  web:
    image: ${DOCKER_REGISTRY-}web
    build:
      context: .
      dockerfile: src/WebManagement/Web/Dockerfile
    depends_on:
      - customerapi

docker-compose.override.yml file

version: '3.4'

services:
  logserver:
    container_name: logserver
    ports:
      - "5341:80"
    environment:
      - ACCEPT_EULA
      
  sqlserver:
    container_name: sqlserver
    ports:
      - "5433:1433"
    volumes:
      - sqlserverdata:/var/opt/mssql
    environment:
      - ACCEPT_EULA=Y
      - MSSQL_PID=Developer
      - SA_PASSWORD=Pass@word

  rabbitmq:
    container_name: rabbitmq
    ports:
      - "15672:15672"
      - "5672:5672"
    volumes:
      - rabbitmqdata:/var/lib/rabbitmq    
    environment:
      - RABBITMQ_DEFAULT_USER=rabbitmquser
      - RABBITMQ_DEFAULT_PASS=Pass@word

  customerapi:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "5000:80"

  web:
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - ASPNETCORE_URLS=http://0.0.0.0:80
    ports:
      - "7000:80"

volumes:
  sqlserverdata:
    external: true
  rabbitmqdata:
    external: true

When Refit (RestClient) try to fetch a record from the customerapi (GetCustomers) endpoint, where problem started to happen. I don’t know how to step into other projects while debugging from docker compose. I have set a break point in couple of places but it won’t hit the customerapi controller action method, since it is a micro-service being called by web front end. I have extracted following errors from a long lines of stack traces if you can help:-

[16:02:33 INF] Start processing HTTP request GET http://localhost:5000/api/customers
[16:02:33 INF] Sending HTTP request GET http://localhost:5000/api/customers
"GET CustomerManagement/Index","ai.location.ip":"172.20.0.1","ai.internal.sdkVersion":"rdddsc:2.10.0-32157","ai.internal.nodeName":"ec1567d9102f.(none)"},"data":{"baseType":"RemoteDependencyData","baseData":{"ver":2,"name":"GET /api/customers","id":"|1a08fcc1445823449b91fe1f785d0f1e.da75cb80_1.","data":"http://localhost:5000/api/customers","duration":"00:00:01.5894365","resultCode":"Faulted","success":false,"type":"Http","target":"localhost:5000","properties":{"DeveloperMode":"true","Error":"Cannot assign requested address","AspNetCoreEnvironment":"Production","_MS.ProcessedByMetricExtractors":"(Name:'Dependencies', Ver:'1.1')"}}}}

[11:16:04 INF] Start processing HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 INF] Sending HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 WRN] Error occured during request-execution. Polly will retry. Exception: Cannot assign requested address
web_1          | [11:16:04 INF] Start processing HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 INF] Sending HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 WRN] Error occured during request-execution. Polly will retry. Exception: Cannot assign requested address
web_1          | [11:16:04 INF] Start processing HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 INF] Sending HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 WRN] Error occured during request-execution. Polly will retry. Exception: Cannot assign requested address
web_1          | [11:16:04 INF] Start processing HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 INF] Sending HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 WRN] Error occured during request-execution. Polly will retry. Exception: Cannot assign requested address
web_1          | [11:16:04 INF] Start processing HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 INF] Sending HTTP request GET http://localhost:5000/api/customers
web_1          | [11:16:04 WRN] Error occured during request-execution. Polly will retry. Exception: Cannot assign requested address


I have tried to run your project but it also give me problem same at WorkshopmanagementAPI but it does display customer and vehicle api. I don’t understand where is the problem. I have spent quite a bit time to do a research on it, but could not find any answer therefore i have posted for your help. Hope you won’t mind it.

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Urgen-Dorjeecommented, Aug 31, 2019

We are good now!!

Thanks

1reaction
EdwinVWcommented, Aug 29, 2019

I’ve looked at the code in the EnsureDatabase method and found the issue. It is the call to conn.Open() that is the culprit. This will throw an exception when the SQL Server instance is not yet up. To fix this, I’ve wrapped all open calls with a retry (812ad300ae069852ca5cc9ec5da0f2ea731e9e11).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Running identical docker container offline - Stack Overflow
In your situation I would recommend using a docker-compose.override.yml . This allows you to keep your production file untouched but set ...
Read more >
Use Docker containers in disconnected environments
When operating Docker containers in a disconnected environment, the container will write usage records to a volume where they're collected over ...
Read more >
docker container ls
--all , -a, Show all containers (default shows just running). --filter , -f, Filter output based on conditions provided. --format, Pretty-print containers ......
Read more >
Engine API v1.24 - Docker Documentation
all – 1/True/true or 0/False/false, Show all containers. Only running containers are shown by default (i.e., this defaults to false); limit – Show...
Read more >
Frequently asked questions - Docker Documentation
When downloading and installing Docker Desktop, you are asked to agree to the ... work while using Docker Desktop offline or in air-gapped...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found