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

Running in Docker/Kubernetes #72

Open
domderen opened this issue May 1, 2021 · 2 comments
Open

Running in Docker/Kubernetes #72

domderen opened this issue May 1, 2021 · 2 comments

Comments

@domderen
Copy link

domderen commented May 1, 2021

Hi,

I'm wondering if you might have some examples of how to use this library inside Docker/Kubernetes environment? I running into issues when trying to set it up in such an environment.

I tried running the container with such parameters:

index.js

const mdnsService = require('multicast-dns')

const port = process.env.PORT || 53

const server = mdnsService({
  port
})

server.on('query', function (query) {
  console.log('DNS Query:', query.questions)
})

console.log(`Box up & running on port ${port}.`);

['SIGHUP', 'SIGINT', 'SIGQUIT', 'SIGILL', 'SIGTRAP', 'SIGABRT',
    'SIGBUS', 'SIGFPE', 'SIGUSR1', 'SIGSEGV', 'SIGUSR2', 'SIGTERM'
].forEach(function (sig) {
    process.on(sig, function () {
      console.log('Box is shutting down.')
      server.destroy()
    })
})

Dockerfile

FROM node:current-alpine3.13
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# update and install dependency
RUN apk update && apk upgrade
RUN apk add git

# copy the app, note .dockerignore
COPY package*.json /usr/src/app/
RUN npm install

COPY . /usr/src/app/

CMD [ "node", "index.js" ]

Commands to build & run the container:

docker build -t multicast-dns .
docker run -it -e PORT=53 -p 53:53/udp -p 53:53/tcp multicast-dns

Command to test the app:

dig @127.0.0.1 +tries=1 +time=1 some.domain.name.com

The above command works fine when I run this app via node index.js and I can see the log statement for the DNS query. But when I run it in docker, it looks like my diq requests are not coming through.

Thanks in advance for your help!

@johnwoo-nl
Copy link

mDNS uses UDP port 5353, not port 53 like regular DNS. See: https://datatracker.ietf.org/doc/html/rfc6762#appendix-A
So I'm kind of surprised that you mention it does work when run outside of a docker container.

@slavaGanzin
Copy link

slavaGanzin commented May 5, 2023

@johnwoo-nl Systemd-resolved will pickup anything from 5353
https://wiki.archlinux.org/title/Systemd-resolved#mDNS

and I assume this behavior is mirrored on other OSes

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