1

在 DockerCloud 中,我试图让我的容器与另一个容器对话。我认为问题是主机名无法解析(/conf.d/kafka.yaml如下所示)。

为了让 DockerCloud 让两个容器进行通信,我尝试了很多变体,包括完整的主机名kafka-development-1kafka-development-1.kafka等。

我不断收到的错误出现在datadog-agent info中:

在我运行./etc/init.d/datadog-agent info并接收的容器内:

kafka
-----
  - instance #kafka-kafka-development-9092 [ERROR]: 'Cannot connect to instance 
    kafka-development:9092 java.io.IOException: Failed to retrieve RMIServer stub: 
    javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is: \n\tjava.net.SocketException: Connection reset]' collected 0 metrics
  - Collected 0 metrics, 0 events & 0 service checks

我采取的详细步骤

SSH 进入 Docker 节点:

$ docker ps

CONTAINER | PORTS 
datadog-agent-kafka-development-1.2fb73f62 | 8125/udp, 9001/tcp 
kafka-development-1.3dc7c2d0 | 0.0.0.0:9092->9092/tcp

我登录容器查看它们的值,这是datadog-agent

$ docker exec -it datadog-agent-kafka-development-1.2fb73f62 /bin/bash

$ > echo $DOCKERCLOUD_CONTAINER_HOSTNAME
    datadog-agent-kafka-development-1

$ > tail /etc/hosts
    172.17.0.7  datadog-agent-kafka-development-1
    10.7.0.151  datadog-agent-kafka-development-1

这是卡夫卡容器

$ docker exec -it kafka-development-1.3dc7c2d0 /bin/bash

$ > echo $DOCKERCLOUD_CONTAINER_HOSTNAME                                                                                                                     
    kafka-development-1

$ > tail /etc/hosts
    172.17.0.6  kafka-development-1
    10.7.0.8    kafka-development-1

$ > echo $KAFKA_ADVERTISED_HOST_NAME
    kafka-development.c23d1d00.svc.dockerapp.io

$ > echo $KAFKA_ADVERTISED_PORT
    9092

$ > echo $KAFKA_ZOOKEEPER_CONNECT
    zookeeper-development:2181

数据狗conf.d/ kafka.yaml :

 instances:
   - host: kafka-development
     port: 9092 # This is the JMX port on which Kafka exposes its metrics (usually 9999)
     tags:
       kafka: broker
       env: development
  # ... Defaults Below

谁能看到我做错了什么?

4

0 回答 0