다음과 같은 docker-compose.yml이 주어졌습니다. 서비스 kafka를 확장하고 싶지만 특정 포트를 지정하지는 않습니다. 환경 변수 설정은 docker-compose에 의해 contextual assigned port를 보간 할 수 있어야한다. 그게 가능하니? 즉 현재 불가능하므로할당 된 포트의 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