[英]Understanding Hostname of Containers in docker-compose.yml
I am trying to understand a docker-compose.yml
(also shown at the bottom of this post). 我正在尝试了解
docker-compose.yml
(也显示在本文的底部)。
Question: confluent:2181
is used the following line 问题:
confluent:2181
用于以下行
KAFKA_ZOOKEEPER_CONNECT: "confluent:2181"
How was this confluent
hostname defined? 这个
confluent
主机名是如何定义的? If I understand hostnames in Docker correctly, the only container hostnames are zookeeper
, kafka
, rest-proxy
and schema-registry
. 如果我正确理解了Docker中的主机名,则唯一的容器主机名是
zookeeper
, kafka
, rest-proxy
和schema-registry
。
docker-compose.yml docker-compose.yml
version: "2"
services:
zookeeper:
image: confluent/zookeeper
ports:
- "2181:2181"
environment:
zk_id: "1"
network_mode: "host"
kafka:
image: confluent/kafka
depends_on:
- zookeeper
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: "confluent:2181"
network_mode: "host"
rest-proxy:
image: confluent/rest-proxy
depends_on:
- zookeeper
- kafka
- schema-registry
ports:
- "8082:8082"
environment:
RP_ZOOKEEPER_CONNECT: "confluent:2181"
RP_SCHEMA_REGISTRY_URL: "http://confluent:8081"
network_mode: "host"
schema-registry:
image: confluent/schema-registry
depends_on:
- kafka
- zookeeper
ports:
- "8081:8081"
environment:
SR_KAFKASTORE_CONNECTION_URL: "confluent:2181"
network_mode: "host"
You're right. 你是对的。 According to the
docker-compose.yml
the services being defined will provide DNS resolution only for zookeeper
, kafka
, rest-proxy
and schema-registry
, and not confluent
. 根据
docker-compose.yml
,定义的服务将仅为zookeeper
, kafka
, rest-proxy
和schema-registry
提供DNS解析,而不会confluent
。
However if you take a look at the documenttion from confluentinc they require you to modify your hosts file in your host machine: 但是,如果您查看confluentinc的文档,它们会要求您修改主机中的主机文件:
Edit your hosts file and add a host entry for the docker machine.
编辑您的主机文件并为Docker计算机添加主机条目。
192.168.99.100 confluent
192.168.99.100汇合
That's why you can use confluent
and get name resolution. 这就是为什么您可以使用
confluent
并获得名称解析的原因。 It doesn't have anything to do with docker or compose. 它与docker或compose无关。
PS: Beware that you're using deprecated images according to their documentation PS:请注意, 根据其文档 ,您正在使用不推荐使用的图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.