Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get it running on linux #21

Closed
RobertHeim opened this issue May 31, 2019 · 4 comments
Closed

Can't get it running on linux #21

RobertHeim opened this issue May 31, 2019 · 4 comments

Comments

@RobertHeim
Copy link
Contributor

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?

@RobertHeim
Copy link
Contributor Author

It is a firewall issue. The host firewall must allow the dockerhost container to access the relevant port.

Get the relevant port of the container:

sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' d_dockerhost_1
172.22.0.2

Allow the container's ip to access the port on the host, here using ufw:

sudo ufw allow from 172.22.0.2 proto tcp to any port 2323

done :)

@qoomon
Copy link
Owner

qoomon commented May 31, 2019

glad to here that.

@lrkwz lrkwz mentioned this issue Sep 3, 2019
@meijieru
Copy link

@qoomon Could you please update the README for a more general command? I still mess up with the command.

@qoomon
Copy link
Owner

qoomon commented Dec 30, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants