I needed to test my kafka
consumer and message triggers in a controlled environment. So I made an ansible
project for creating some mock kafka
servers: mokafelk.
It works fine except the security is shit. The playbook
spins up a 3-node dockerized
kafka
cluster by default but the listening ports on the kafka servers are exposed to all. Here's the jinja2
template of the Dockerfile
used for creating the cluster.
Basically I want the containers to be able to talk to each other. I don't think container linking is an option because it seems to me linking is only one-way. But exposing a port using 127.0.0.1:{{ port }}:{{ port }}
only exposes the port to the hosting machine and does not expose the port to the other containers if I am correct. 0.0.0.0:{{ port }}:{{ port }}
exposes the port to the whole world. So how could I link two+ containers both ways? This must be a common problem but I don't seem to find a quick solution...