Cannot produce message to kafka from service running in docker

I’ve a rest service running in docker container on port 5000 which is used to produce message over kafka topic running out of docker container.

I’ve configure my producer client with below properties :-

  • Using Marathon json to create new implementations
  • docker upgrade - grub error
  • Docker - Using Composer inside PHP container
  • Installation is not happening according to Docker file
  • Not able to run the default hello-world program in docker on Windows 7
  • openshift origin with local docker registry
  • bootstrap.servers=localhost:9093

    And I’ve started my contained with below command:-

    docker run -d -p <contained id>

    I’ve also made below configuration to advertise kafka host and port

    Despite of having all configuration when I try to produce to a kafka topic then I get below error:-

    org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

    Can someone please point where the actual problem is?

  • Connect tomcat container to mysql container
  • How to install features in WSO2 using a shell script
  • What might cause a docker container to execute an su command differently on two hosts?
  • SSH Tunneling to docker container
  • NodeJS: Can't connect to postgreSQL container from another container
  • Increase Disk Space on Docker Toolbox
  • One Solution collect form web for “Cannot produce message to kafka from service running in docker”

    In real life, should never be localhost.

    In your case, you run your Docker container in bridge networking mode, so it won’t be able to reach the broker via localhost, as it will point to the container network, not the host machine.

    To make it work you should set the and bootstrap.servers to the IP address returned by ifconfig docker0 (might be not docker0 in your case but you get the point).

    Alternatively, you may probably run your container with --net=host, but I think you’d better properly configure the advertised host name.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.