I am trying to use the bridged network `d_backend` to communicate between `nc` listening on the host service and a docker container emitting messages. This is the network ``` $ sudo docker network ls NETWORK ID NAME DRIVER SCOPE fdc454526116 d_backend bridge local ``` ``` $ sudo docker network inspect d_backend --format='{{( index .IPAM.Config 0).Gateway}}' 172.22.0.1 ``` On the host I bind nc to that ip: ``` nc 172.22.0.1 2323 -lk ``` This is my docker-compose.yml ``` version: '3.5' services: dockerhost: image: qoomon/docker-host cap_add: - NET_ADMIN - NET_RAW restart: on-failure networks: - backend tcp_message_emitter: image: alpine depends_on: - dockerhost command: [ "sh", "-c", "while :; do date; sleep 1; done | nc 'dockerhost' 2323 -v"] networks: - backend networks: backend: driver: bridge ``` I run this (within folder `d` so that the correct network is used) ``` /home/foo/d$ sudo docker-compose up Starting d_dockerhost_1 ... done Starting d_tcp_message_emitter_1 ... done Attaching to d_dockerhost_1, d_tcp_message_emitter_1 dockerhost_1 | Docker Host: 172.22.0.1 (default gateway) ``` I would expect to see a date on the host every second, but I don't. Any ideas?
Activity
RobertHeim commentedon May 31, 2019
It is a firewall issue. The host firewall must allow the
dockerhostcontainer to access the relevant port.Get the relevant port of the container:
Allow the container's ip to access the port on the host, here using ufw:
done :)
qoomon commentedon May 31, 2019
glad to here that.
meijieru commentedon Dec 30, 2019
@qoomon Could you please update the README for a more general command? I still mess up with the command.
qoomon commentedon Dec 30, 2019