dockerapache-kafkadocker-compose

How docker map env variable to kafka broker variable?


I'm new to Docker, and trying to understand how it works Reading this Kafka docker Image

https://github.com/conduktor/kafka-stack-docker-compose/blob/master/zk-multiple-kafka-single.yml

Here you can see many variables are defined with their values. To run Kafka using docker, I need to download this docker image on my local machine, and docker will run kafka's image in container.

Upto here, I'm good. Downloading and running using Docker...

My doubt is, If you see any variable in zk-multiple-kafka-single.yml, lets say for example KAFKA_AUTHORIZER_CLASS_NAME env variable and its value kafka.security.authorizer.AclAuthorizer

When we install kafka with zookeeper manually, we need to set this property in server.properties file as authorizer.class.name=kafka.security.authorizer.AclAuthorizer

So, when we run docker image, How come KAFKA_AUTHORIZER_CLASS_NAME gets mapped to authorizer.class.name in server.properties file ? Which part of docker doing this ? I'm not able to get this

I thought, all variable names which are mentioned in docker's yml file, are also part of KAFKA somewhere too, and docker knows where and in which file it needs to be added, but its not, something else is happening which I'm not able to understand

Can anyone please help me to understand this ?


Solution

  • This is unrelated to Docker itself. It's tied to a template file within the Kafka image provided by Confluent: kafka.properties.template. This template is processed by the configure script when the container starts, where the env variables are actually used to build the configuration (kafka.properties) file before starting Kafka itself.