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 :-

  • dante-sever fail to bind ip by interface name in docker container
  • Build Docker image in Jenkins (in Docker image) - Cloud docker agent
  • Error when creating a Docker container with MongoDB in it
  • Access host filesystem in the docker compose command
  • Configuring riak-ruby to work with docker cluster
  • Copying file from host to container
  • 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?

  • How to set an environment variable in a running docker container
  • Connecting to localhost mysql server from inside docker container on macOS
  • docker not unzipping my files
  • Rancher: NFS or convoy-nfs?
  • how to pass a --login into docker build
  • Get dockerfile / docker commands from docker image
  • 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.