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: 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.
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 “”)? 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!

  • Accessing a Docker MySQL server from the host machine, without needing the container's IP address
  • Docker: Mysql crashes after few seconds when it has been started
  • Docker: Can a secret created and deleted in a single RUN command be recovered from the resulting image?
  • zsh: command not found: dcos
  • Emscripten “incoming” installation unusually big
  • Android instrumentation test with Bitbucket pipelane and Docker
  • Use data of docker container inside another
  • Error while setting up docker dev env
  • API server failed to start up
  • Restarting machines in a docker swarm on AWS
  • Docker containers gone after a while in CoreOS
  • Should I add the reverse proxy in the same container as the application on docker?
  • 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.