Skip to content

Can't get it running on linux #21

Closed

Description

@RobertHeim

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

  1. RobertHeim commented on May 31, 2019

    @RobertHeim
    ContributorAuthor

    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 :)

  2. qoomon commented on May 31, 2019

    @qoomon
    Owner

    glad to here that.

  3. meijieru commented on Dec 30, 2019

    @meijieru

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

  4. qoomon commented on Dec 30, 2019

    @qoomon
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions