publishing message to external Kafka Broker from docker container

In my IDE, I am able to utilize a spring-boot application that would produce message(with Kafkaproducer) to an external kafka broker. But once I have hosted my spring-boot application in docker container, my application can no longer submit to the broker.
Here is the error message:

    o.s.k.support.LoggingProducerListener: Exception thrown when sending a message with key='null' and payload='....' to topic Category: 
org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.
    org.springframework.kafka.core.KafkaProducerException: 
Failed to send; nested exception is org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

what I used to run docker was: docker run -p 9001:9001 -d image_name in which 9001 is my spring-boot port, I am able to Post to the port, just that once my message was posted, it won’t get to the external broker.
I think I have the general concept that Docker containers are living in isolated land where you have to open/map the port in order to access it(like my -p 9002:9002), but does it work the same way to access out from container? if so, can someone please show me how I can run the docker container in order to be able to access to the external broker(let’s say the broker URL is “192.168.1.1:9000”)? I don’t think I am able to modify anything on the broker now, but my assumption is that if I can access via my IDE, why not in docker? Thanks for all the help!

  • Google Container Engine: Accessing Cloud Storage
  • Couldn't connect to Docker daemon on Mac OS X
  • Docker environment variables, dokku-redis
  • How to start an LXC container inside a Docker container
  • Using MySQL with Spring boot docker image
  • How to do --rm and --restart in dockerfile?
  • How does Docker name repositories?
  • Multiple static IPs for Docker containers
  • Cannot install perl module PerlIO::locale within docker
  • replica Set mongo docker-compose
  • Creating a swarm cluster with Docker for Mac
  • how to select options properly for “/bin/bash” when writing a blueprint for cloudify
  • One Solution collect form web for “publishing message to external Kafka Broker from docker container”

    it was due to my ip-forwarding = 0, once that is turned on I am able to do outgoing request.

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