Closed codeasashu closed 2 years ago
I am running this on an Ubuntu VM, which is using DHCP, so the IP isn't predictable. I added the following to my bash startup script (you could use ~/profile
- I used /etc/bash.bashrc
so it worked on all users) to export the DOCKER_HOST_IP:
# set DOCKER_HOST_IP
export DOCKER_HOST_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
This exported the environment variable, but the background start still didn't work properly until I did this:
sudo --preserve-env=DOCKER_HOST_IP docker-compose up -d
Closing this as inactive
I forgot to set the
DOCKER_HOST_IP
environment variable before launching the stack bydocker-compsoe -f zk-single-kafka-single.yml up -d
. It did launched and everything seemed alright until I wrote a consumer in PHP using librdkafka and php-rdkafka.The php code wasn't able to connect to kafka instance. Upon checking the kafka logs in the stack
docker-compose -f zk-single-kafka-single.yml
I see this:I couldn't figure this out for couple of hours until I stopped the stack, set the
DOCKER_HOST_IP
env var and starting the stack up again. It worked perfectly after.IMO, you can provide a entrypoint script which can halt the startup if env var is unavailable or if possible can use the DNS if provided