I have a Kafka consumer which I am realising using Docker. When the Docker container is launched via Terminal, the execution of the docker is running smoothly as the container consumes the message once a producer produces one, when I am doing the same operation but running the container using Docker SDK for python, the container does not consume the message in the sense that the message arrives but then it seems like he is not consuming the message as in the Kafka topic I still find the message and the docker do not continue its execution.
I leave to you the command which I am using to execute my docker via terminal:
docker run -it kafka_consumer python3 consumer.py wow39 172.16.0.206 9092 inception_resnet_v2 TFHub
This is the code that I am running on python to launch the docker:
cmd= "python3 consumer.py "+str(name_app)+" 172.16.0.206 9092 "+str(ml_model)+" "+ml_type
print(cmd)
container = client.containers.run(image ="kafka_consumer" , command= cmd , name=str(name_app)+"_"+str(ml_model), detach=True)
timeout = 5
stop_time = 20
elapsed_time = 0
while container.status != 'running' and elapsed_time < timeout:
sleep(stop_time)
elapsed_time += stop_time
print("stop time: "+str(stop_time))
continue