Skip to content

Running in Docker/Kubernetes #72

@domderen

Description

@domderen

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions