Docker容器名称未解析为DNS,无法访问覆盖网络

时间:2015-11-27 17:11:26

标签: amazon-web-services networking docker docker-compose docker-swarm

我有一个由kafka制作人和另一个kafka消费者组成的应用程序。我正在尝试将其部署在AWS上的Docker swarm中,并启用了多主机网络。 Kafka容器由以下ActiveRecord::Schema.define(version: 20151124163435) do create_table "categories", force: :cascade do |t| t.integer "item_detail_id" t.string "category_for_item" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "item_details", force: :cascade do |t| t.string "item_code_or_name" t.string "details" t.decimal "normal_price" t.decimal "retail_price" t.decimal "wholesale_price" t.datetime "created_at", null: false t.datetime "updated_at", null: false end end 文件创建:

docker-compose.yml

这就是我为不同组件运行容器的方法:

kafka:
  image: spotify/kafka
  environment:
    ADVERTISED_PORT: 9092
  ports:
    - "2181:2181"
    - "9092:9092"

当我查看> docker-compose -f helloworld_kafka.yml --x-networking up -d Creating network "helloworld" ... > docker run -d --name helloworld_producer_1 --net helloworld -it elsoufy/myimage ./myexec -role producer -queue helloworld_kafka_1:9092 > docker run -d --name helloworld_consumer_1 --net helloworld -it elsoufy/myimage ./myexec -role consumer -queue helloworld_kafka_1:9092 的{​​{1}}时,我找到了/etc/hostshelloworld_kafka_1的条目:

helloworld_server_1

但是当我检查后者的日志时,我意识到他们无法连接到kafka。我看到以下内容:

helloworld_consumer_1

看起来当10.0.0.2 kafka_container_id 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 10.0.0.3 helloworld_server_1 10.0.0.3 helloworld_server_1.helloworld 10.0.0.4 helloworld_consumer_1 10.0.0.4 helloworld_consumer_1.helloworld 是容器用来解析名称并且无法访问的DNS(端口> docker logs consumer_container_id 2015/11/27 16:05:52 Kafka brokers: helloworld_kafka_1:9092 2015/11/27 16:05:52 Failed to start consuming dial tcp: lookup kafka_container_id on 10.10.0.2:53: no such host )时。当我检查任何节点的网络时,我找不到这个地址,并且它不在10.10.0.2覆盖网络的范围内。我如何才能使这个DNS可达?任何建议都表示赞赏。

0 个答案:

没有答案