JetBrains Rider 调试 Docker Compose 引发异常“名称或服务未知”

Posted

技术标签:

【中文标题】JetBrains Rider 调试 Docker Compose 引发异常“名称或服务未知”【英文标题】:JetBrains Rider Debugging Docker Compose Throws Exception "Name or service not known" 【发布时间】:2021-04-12 18:36:57 【问题描述】:

当我尝试使用 Rider 调试 docker-compose 时,部署后出现错误。

错误; Error Image On Rider 但我可以用 Visual Studio for mac 调试(非常慢)

我做了什么尝试找到解决方案:

    使用 Rider 重新创建 docker-compose 文件。 我确实添加了调试配置 .override 文件。

我的配置是这样的 操作系统 Mac OS Catalina 10.15.7

JetBrains Rider 2020.3.4 构建 #RD-203.7717.10,构建于 2021 年 3 月 17 日

Configuration

我的 docker-compose 文件也像

version: '3.4'

services:
 elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
    environment:
      discovery.type: single-node
    ports:
      - "9200:9200"
      - "9300:9300"
 kibana:
    image: docker.elastic.co/kibana/kibana:7.10.1
    ports:
      - "5601:5601"
    depends_on:
      - elasticsearch
 apm-server:
    image: docker.elastic.co/apm/apm-server:7.10.1
    ports:
      - "8200:8200"
    depends_on:
      - elasticsearch
 redis:
    image: redis
    ports:
      - "6379:6379"
 postgres:
    image: postgres:13
    environment:
      POSTGRES_PASSWORD: 123
    ports:
      - "5432:5432"
 pgadmin:
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_PASSWORD: ""
      PGADMIN_DEFAULT_EMAIL: ""
    ports:
      - "81:80"
 api:
    build:
      context: .
      dockerfile: Web.API/Dockerfile.dev
    ports: 
      - "5000:5000" 
    environment:
      ASPNETCORE_ENVIRONMENT: Staging
      ASPNETCORE_URLS: http://*:5000
      ELASTIC_APM_CLOUD_PROVIDER: none
      ELASTIC_APM_SERVICE_NAME: api
      ELASTIC_APM_SERVER_URLS: http://apm-server:8200
      ELASTIC_APM_CAPTURE_BODY: all
    depends_on: 
      - postgres
      - redis
 cp-zookeeper:
    image: confluentinc/cp-zookeeper:6.0.1
    hostname: zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

 cp-broker:
    image: confluentinc/cp-kafka:latest
    hostname: broker
    container_name: broker
    depends_on:
      - cp-zookeeper
    ports:
      - "29092:29092"
      - "9092:9092"
    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:29092,PLAINTEXT_HOST://localhost:9092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS: broker:29092
      CONFLUENT_METRICS_REPORTER_ZOOKEEPER_CONNECT: zookeeper:2181
      CONFLUENT_METRICS_REPORTER_TOPIC_REPLICAS: 1
      CONFLUENT_METRICS_ENABLE: 'false'
 cp-schema-registry:
    image: confluentinc/cp-schema-registry:6.0.1
    hostname: schema-registry
    container_name: schema-registry
    depends_on:
      - cp-zookeeper
      - cp-broker
    ports:
      - "8081:8081"
    environment:
      SCHEMA_REGISTRY_HOST_NAME: schema-registry
      SCHEMA_REGISTRY_KAFKASTORE_CONNECTION_URL: 'zookeeper:2181'
 connect-file-pulse:
    image: streamthoughts/kafka-connect-file-pulse:latest
    container_name: connect
    depends_on:
     - cp-broker
     - cp-schema-registry
    ports:
     - "8083:8083"
     - "8000:8000"
    environment:
      CONNECT_BOOTSTRAP_SERVERS: 'broker:29092'
      CONNECT_REST_ADVERTISED_HOST_NAME: connect
      CONNECT_REST_PORT: 8083
      CONNECT_GROUP_ID: compose-connect-group
      CONNECT_CONFIG_STORAGE_TOPIC: docker-connect-configs
      CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
      CONNECT_OFFSET_FLUSH_INTERVAL_MS: 10000
      CONNECT_OFFSET_STORAGE_TOPIC: docker-connect-offsets
      CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
      CONNECT_STATUS_STORAGE_TOPIC: docker-connect-status
      CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
      CONNECT_KEY_CONVERTER: org.apache.kafka.connect.storage.StringConverter
      CONNECT_VALUE_CONVERTER: org.apache.kafka.connect.json.JsonConverter
      CONNECT_VALUE_CONVERTER_SCHEMA_REGISTRY_URL: http://schema-registry:8081
      CONNECT_INTERNAL_KEY_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_INTERNAL_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      CONNECT_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      # kafka-connect-file-pulse is installed as a confluent-hub component
      CONNECT_PLUGIN_PATH: "/usr/share/java,/usr/share/confluent-hub-components/"
      CONNECT_LOG4J_ROOT_LOGLEVEL: "INFO"
      CONNECT_LOG4J_LOGGERS: org.apache.zookeeper=ERROR,org.I0Itec.zkclient=ERROR,org.reflections=ERROR
       # Uncomment for debugging the connector during development cycle
       # KAFKA_OPTS: "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n"
    volumes:
      - ./connect-data:/tmp/connect-data       
networks:
  default:

有人可以用 Rider 调试 docker-compose 吗?

【问题讨论】:

【参考方案1】:

在 Rider 中调试 compose 容器时出现问题:

https://youtrack.jetbrains.com/issue/RIDER-56654

Rider 正在尝试将调试器附加到所有容器。最近几天我也遇到了同样的问题,这让我很生气!

2021 年 11 月更新:现在看来这个问题已经解决了,我使用的是 2021.2.2 版本。我在让它工作时遇到了一些麻烦,但有一个解决方法https://youtrack.jetbrains.com/issue/RIDER-62838Good Luck!

【讨论】:

这个问题阻止了我从 VS 迁移到 Rider。非常悲惨的情况。 显然这已被修复,但我运气不佳。

以上是关于JetBrains Rider 调试 Docker Compose 引发异常“名称或服务未知”的主要内容,如果未能解决你的问题,请参考以下文章

如何在 Mac 上使用 JetBrains Rider 开发和调试在 Docker 中运行的 .NET Core 应用程序

JetBrains Rider lua怎么连上Unity调试

Jetbrains Rider:在调试器调用堆栈中显示“外部代码”

JetBrains Rider 中 Visual Studio 的“无需调试即可启动”?

调试在 JetBrains Rider 中不起作用的 React Typescript 项目

使用 Dockerfile 使用 Jetbrains Rider 调试 .NET Core 应用程序