Как отладить ядро ​​.net в контейнере? - PullRequest
0 голосов
/ 26 февраля 2019

Я работаю над основным проектом .Net.Там восемь контейнеров работают параллельно.Ниже приведен снимок экрана.

Показывает все контейнеры

enter image description here

Всякий раз, когда я запускаю make start, все контейнеры запускаются, и явозможность запуска моего пользовательского интерфейса и API, а также.Если я захочу внести изменения в UI или API, я внесу изменения в код и перезапущу контейнер. Это будет работать.Я хочу отлаживать API от почтальона.Всякий раз, когда я пытаюсь отладить код API в против кода, но я получаю исключения в коде, где я пытаюсь связаться с другими службами, работающими в контейнере.В моем случае я получаю сообщение об ошибке при установлении соединения с БД Postgres.Ниже мой docker.compose.yml

version: '3.4'

services:
  replenishment-ui:
    build:
      context: ../ipm-ui
      args:
        http_proxy: "${http_proxy}"
        https_proxy: "${https_proxy}"
      network: host # Need access to localhost for cntlm proxy
    image: replenishment-ui
    container_name: replenishment-ui
    links:
      - replenishment-service
    ports:
      - 8080:8080
    environment:
      API_HOST: 'replenishment-service'
      API_PORT: '5000'
      STAGE: 'local'
    volumes:
      - ../ipm-ui/src/:/work/src
    tty: true
    working_dir: /work
    command: "npm run start"

  replenishment-service:
    build:
      context: ./
      dockerfile: Dockerfile
      args:
        http_proxy: "${http_proxy}"
        https_proxy: "${https_proxy}"
      network: host # Need access to localhost for cntlm proxy
    environment:
      AWS_ACCESS_KEY_ID: 'abc'
      AWS_SECRET_ACCESS_KEY: 'abc'
      IPM_POSTGRES_USERNAME: 'kmart'
      IPM_POSTGRES_PASSWORD: 'kmart'
      IPM_POSTGRES_DATABASE: 'kmart'
      IPM_POSTGRES_ADDRESS: 'replenishment-postgres'
      IPM_POSTGRES_PORT: '5432'
      IPM_DB2_PASSWORD: 'paoi87y87y'
      IPM_DB2_USERNAME: 'db2inst1'
      IPM_KAFKA_SASL_USERNAME: 'kmart'
      IPM_KAFKA_SASL_PASSWORD: 'kmart'
      IPM_DSS_LOCAL_SQS_URL: 'http://replenishment-goaws:4100'
      IPM_DSS_SQS_URL: 'http://replenishment-goaws:4100/queue/local-queue1'
      ASPNETCORE_ENVIRONMENT: 'local'
      EXECUTE_INITIAL: 'true'
      http_proxy: 'http://httpgw.core.kmtltd.net.au:8080'
      https_proxy: 'http://httpgw.core.kmtltd.net.au:8080'
    image: replenishment-service
    container_name: replenishment-service
    ports:
      - 5000:5000
    links:
      - replenishment-postgres
      - db2
      - goaws
    depends_on:
      - replenishment-postgres

  goaws:
    image: pafortin/goaws
    container_name: replenishment-goaws
    ports:
      - 4100:4100

  replenishment-postgres:
    build:
      context: ./replenishment_data
    image: replenishment-postgres
    container_name: replenishment-postgres
    command: ["postgres", "-c", "log_statement=all"]
    volumes:
      - pg-data-cache:/var/lib/postgresql/data/
    ports:
      - 5432:5432

  db2:
    build:
      context: .
      dockerfile: Dockerfile-db2local
      args:
        http_proxy: "${http_proxy}"
        https_proxy: "${https_proxy}"
        LICENSE: 'accept'
    image: db2-local
    container_name: db2
    ports:
      - 50001:50001
    environment:
      LICENSE: 'accept'
      DB2INST1_PASSWORD: 'paoi87y87y'
    volumes:
      - ./scripts/db2:/scripts
      - db2-data-cache:/home/db2inst1/
    command: ["db2start"]

  zookeeper:
    image: confluentinc/cp-zookeeper:5.0.0
    hostname: zookeeper
    container_name: zookeeper
    logging:
      driver: none
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  broker:
    image: confluentinc/cp-enterprise-kafka:5.0.0
    hostname: broker
    container_name: broker
    logging:
      driver: none
    depends_on:
      - zookeeper
    ports:
      - "9092:9092"
      - "29092:29092"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_METRIC_REPORTERS: io.confluent.metrics.reporter.ConfluentMetricsReporter
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
      CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: broker:9092
      CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: zookeeper:2181
      CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
      CONFLUENT_METRICS_ENABLE: 'true'
      CONFLUENT_SUPPORT_CUSTOMER_ID: 'anonymous'

  schema-registry:
    image: confluentinc/cp-schema-registry:5.0.0
    hostname: schema-registry
    container_name: schema-registry
    logging:
      driver: none
    depends_on:
      - zookeeper
      - broker
    ports:
      - "8081:8081"
    environment:
      SCHEMA_REGISTRY_HOST_NAME: schema-registry
      SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'

volumes:
  db2-data-cache:
  pg-data-cache:

Ниже трассировки стека.

Unhandled Exception: System.ArgumentException: Host can't be null
   at Npgsql.NpgsqlConnector.<Open>d__143.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Npgsql.NpgsqlConnection.<Open>d__28.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Npgsql.NpgsqlConnection.Open()
   at Microsoft.EntityFrameworkCore.Storage.Internal.NpgsqlDatabaseCreator.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabaseFacade databaseFacade)
   at IPM.ReplenishmentService.DataContext.ReplenishmentParameterContext..ctor(DbContextOptions`1 options, Boolean migrate) in C:\Users\ngodbole\Documents\GitHub\GitTest\ipm-service\ReplenishmentService\DataContext\ReplenishmentParameterContext.cs:line 15
   at IPM.ReplenishmentService.Startup.ConfigureServices(IServiceCollection services) in C:\Users\ngodbole\Documents\GitHub\GitTest\ipm-service\ReplenishmentService\Startup.cs:line 99
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at IPM.ReplenishmentService.Program.BuildWebHost_NotRunByMigrations(String[] args) in C:\Users\ngodbole\Documents\GitHub\GitTest\ipm-service\ReplenishmentService\Program.cs:line 31
   at IPM.ReplenishmentService.Program.Main(String[] args) in C:\Users\ngodbole\Documents\GitHub\GitTest\ipm-service\ReplenishmentService\Program.cs:line 14

Могу ли я узнать, каковы подходы для локальной отладки API?Если кто-то поможет мне с доступными подходами к отладке, это будет действительно полезно.Любая помощь будет оценена.Спасибо

...