给定以下docker-compose.yml。我想扩展服务kafka,但不分配任何特定的端口。环境变量配置应该能够通过docker-compose插入上下文分配的端口。那可能吗?Docker组合,指定端口的插值
zookeeper:
image: wurstmeister/zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka
ports:
- "9092" #I am not assigning a remote port here, leaving that to docker-compose
links:
- zookeeper:zk
environment:
KAFKA_PORT: 9092
KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://localhost:9092, PLAINTEXT://localhost:${ASSIGNED_PORT}" # I would like ASSIGNED_PORT here to be the assigned port of docker-compose
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: "1"
volumes:
- /var/run/docker.sock:/var/run/docker.sock