• JavaScript 100%
Find a file
Christian Fritz 32a0d0498c 1.0.3
2026-01-11 09:37:08 -08:00
index.js Use image name instead of containername (more reliable) 2026-01-11 09:36:44 -08:00
package-lock.json 1.0.3 2026-01-11 09:37:08 -08:00
package.json 1.0.3 2026-01-11 09:37:08 -08:00
README.md Added example to readme 2025-11-11 14:18:01 -08:00

mdns-docker

A tiny script that will provide fuzzy-matched DNS name resolution for docker containers.

Example

Say you have the following containers running:

server
app
cloud-clickhouse-1
transitive-robotics.ros-tool.0.4

With this script running you can do

ping click.docker.local

and it will auto-resolve that name to the IP of the cloud-clickhouse-1 container.

Usage

Run this package anywhere using npx mdns-docker (npx will ask to install the package).

This script allows you do to "ping my-container.docker.local" and it will "just work". The way it does it is by running a local mDNS service that listens to *.docker.local requests, finds a running container whose name contains the name (here: "my-container"), get that container's local IP address, and respond to the mDNS query with that IP.

Example

# start this service
npx mdns-docker

# Start a ClickHouse service (as an example)
docker run --rm --name myclicky clickhouse:25.7

and now open `http://myclick.docker.local:8123" to open the built-in dashboard (there is a short delay) -- no port mapping required!