Я не могу достучаться до net основного приложения внутри docker контейнера - PullRequest
0 голосов
/ 16 июня 2020

У меня есть основное приложение. net, работающее внутри контейнера docker. Также контейнер postgres в той же сети. Я вижу это. net Приложение cora достигает postgre и регистрирует информацию о нем. Но я не могу получить доступ к основному приложению. net в моем браузере.

Я работаю с Visual Studio 2019 Community Edition. Запускаю проект docker -compose и пытаюсь отреагировать https://localhost: 5555 / hangfire , тогда я получил 404. Я получаю 404 для всех конечных точек api.

Это сеть, в которой я создать внутри docker. Я вижу оба контейнера в сети

$ docker network inspect mynet
[
{
    "Name": "mynet",
    "Id": "7624ea1f6332e89499285eed2532265ca47d5073542f22d340bc332d9e3eb606",
    "Created": "2020-06-15T14:19:52.1636051Z",
    "Scope": "local",
    "Driver": "bridge",
    "EnableIPv6": false,
    "IPAM": {
        "Driver": "default",
        "Options": {},
        "Config": [
            {
                "Subnet": "172.18.0.0/16",
                "Gateway": "172.18.0.1"
            }
        ]
    },
    "Internal": false,
    "Attachable": false,
    "Ingress": false,
    "ConfigFrom": {
        "Network": ""
    },
    "ConfigOnly": false,
    "Containers": {
        "95911a29d1bcd3a6d0f614238bfe5a8e3a508a51e589129d9984996c1b4ee0eb": {
            "Name": "hangfire_postgre",
            "EndpointID": "54471f67fd0a37ff983f916706fb615465f0aedfa90dfb7fd2861a90aa059942",
            "MacAddress": "02:42:ac:12:00:02",
            "IPv4Address": "172.18.0.2/16",
            "IPv6Address": ""
        },
        "de058313208f318194e7bcac88e13d5c66afca9625484fc4c72b8c77108e7a10": {
            "Name": "CommunicationAnalytics",
            "EndpointID": "218951a0c729d3a9533573b6e1fe564d8e859bc04dad2350b69fb6b419a81f7b",
            "MacAddress": "02:42:ac:12:00:03",
            "IPv4Address": "172.18.0.3/16",
            "IPv6Address": ""
        }
    },
    "Options": {},
    "Labels": {}
}
]

docker -compose.override.yml для CommunicationAnalytics. Я не публикую docker -compose.yml, это просто build, context и dockerfile.

version: '3.4'

services:
  communicationanalytics:
    environment:
      - ASPNETCORE_ENVIRONMENT=DevLinux
      - ASPNETCORE_URLS=https://*:443;http://*:80
      - ASPNETCORE_Kestrel__Certificates__Default__Password=mypass
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/root/.aspnet/https/CommunicationAnalytics.pfx
    ports:
      - 5554:80
      - 5555:443
    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro

networks:
  default:
      external:
          name: mynet

Это вывод журнала. net core app.

warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
info: Hangfire.PostgreSql.PostgreSqlStorage[0]
      Start installing Hangfire SQL objects...
info: Hangfire.PostgreSql.PostgreSqlStorage[0]
      Hangfire SQL objects installed.
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {af08df33-f745-4e57-a746-6d2b1a015488} may be persisted to storage in unencrypted form.
info: Hangfire.BackgroundJobServer[0]
      Starting Hangfire Server using job storage: 'PostgreSQL Server: Host: hangfire_postgre, DB: iCAT_Utils, Schema: hangfire'
info: Hangfire.BackgroundJobServer[0]
      Using the following options for SQL Server job storage:
info: Hangfire.BackgroundJobServer[0]
          Queue poll interval: 00:00:15.
info: Hangfire.BackgroundJobServer[0]
          Invisibility timeout: 00:30:00.
info: Hangfire.BackgroundJobServer[0]
      Using the following options for Hangfire Server:

          Worker count: 20

          Listening queues: 'default'

          Shutdown timeout: 00:00:15

          Schedule polling interval: 00:00:15
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop BackgroundServerProcess:5ff57545 has started in 12.7407 ms
info: Hangfire.BackgroundJobServer[0]
      Starting Hangfire Server using job storage: 'PostgreSQL Server: Host: hangfire_postgre, DB: iCAT_Utils, Schema: hangfire'
info: Hangfire.BackgroundJobServer[0]
      Using the following options for SQL Server job storage:
info: Hangfire.BackgroundJobServer[0]
          Queue poll interval: 00:00:15.
info: Hangfire.BackgroundJobServer[0]
          Invisibility timeout: 00:30:00.
info: Hangfire.BackgroundJobServer[0]
      Using the following options for Hangfire Server:

          Worker count: 20

          Listening queues: 'default'

          Shutdown timeout: 00:00:15

          Schedule polling interval: 00:00:15
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop BackgroundServerProcess:e0e6dbd8 has started in 3.3052 ms
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://[::]:443
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://[::]:80
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: DevLinux
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /app
info: Hangfire.Server.BackgroundServerProcess[0]
      Server de058313208f:23:008760c9 successfully announced in 492.7207 ms
info: Hangfire.Server.BackgroundServerProcess[0]
      Server de058313208f:23:c3cac0e6 successfully announced in 405.9416 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ServerHeartbeatProcess:94ed75bc has started in 6.8483 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ServerHeartbeatProcess:211ce44e has started in 6.9179 ms
info: Hangfire.Server.BackgroundServerProcess[0]
      Server de058313208f:23:008760c9 is starting the registered dispatchers: ServerWatchdog, ServerJobCancellationWatcher, ExpirationManager, Worker, DelayedJobScheduler, RecurringJobScheduler...
info: Hangfire.Server.BackgroundServerProcess[0]
      Server de058313208f:23:c3cac0e6 is starting the registered dispatchers: ServerWatchdog, ServerJobCancellationWatcher, ExpirationManager, Worker, DelayedJobScheduler, RecurringJobScheduler...
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ServerJobCancellationWatcher:2b64b59f has started in 22.5967 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ServerWatchdog:a087b51d has started in 28.3681 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ServerJobCancellationWatcher:33324326 has started in 25.3789 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ServerWatchdog:8965897e has started in 26.0621 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ExpirationManager:f4e033d7 has started in 28.0096 ms
dbug: Hangfire.Processing.BackgroundExecution[0]
      Execution loop ExpirationManager:4ba4aee6 has started in 30.5558 ms

И, наконец, это результат docker ps

$ docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                         NAMES
de058313208f        communicationanalytics:dev   "tail -f /dev/null"      38 minutes ago      Up 38 minutes       0.0.0.0:5554->80/tcp, 0.0.0.0:5555->443/tcp   CommunicationAnalytics
95911a29d1bc        postgres                     "docker-entrypoint.s…"   7 hours ago         Up 7 hours          0.0.0.0:5433->5432/tcp                        hangfire_postgre
...