If you are running Docker on Mac OS, then (slightly simplified) you must telnet to the IP address of your Docker Machine, which is the Linux VM in which your actual containers run.
Think: your Mac laptop -> Docker Machine (Linux VM) -> Docker containers.
If you configure your containers to listen on "localhost:29092" (for example), then Docker will make them listen on localhost:29092 in your Linux VM, not on your Mac laptop!
What you would need to do is sth like:
# You should have already done this step, which creates a Docker Machine (VM) named "confluent"
$ docker-machine create --driver virtualbox --virtualbox-memory 6000 confluent
# Next, configure your terminal window to attach it to your new Docker Machine.
$ eval $(docker-machine env confluent)
# Now you can talk to e.g. the broker, but you must telnet to the IP of the Docker Machine.
# Typically, the Docker Machine IP is sth like 192.168.99.100.
$ telnet `docker-machine ip confluent` 29092
Note: When talking to a broker, even if you can successfully telnet to its port, this isn't a proper test that you can successfully write messages to it. If telnet works but producing messages to the broker's endpoint does not, you must configure the broker setting `advertised.listeners` appropriately. This is not an issue of Kafka, but a networking issue caused by how Docker works on Macs (with its awkward requirement of running your containers inside a Linux VM).
Hope this helps,
Michael