使用docker-compose从节点容器绑定到多播UDP套接字

时间:2019-03-18 17:11:55

标签: node.js docker docker-compose udp

如果在docker-compose中使用network_mode: host调出容器,则程序将正常执行。但是,在不将容器映射到主机网络的情况下,我无法弄清楚如何绑定到套接字...

有什么主意吗?

我的docker-compose.yml:

version: '3.6'
services:
  container-one:
    command: ['npm', 'start']
    image: 'ccontainer-one:${VERSION}'
    build:
      context: ./containers/container-one
    restart: always
    networks:
      - consumer
    ports:
      - '55014:55014/udp'
networks:
  consumer:
    driver: bridge

这总是失败:

const dgram = require('dgram')
const socket = dgram.createSocket('udp4')
socket.bind(55014, () => {
  try {
    return socket.addMembership(229.1.80.20, 10.10.5.1)
  } catch (e) {
    throw new Error(`is interface up? can't bind to 229.1.80.20:55014 from 10.10.5.1`)
  }

0 个答案:

没有答案