Docker Name Resolver (DNR) It's a simple way to resolve the Docker container name to it's IP.
1.3K
____ _ ______
/ __ \/ | / / __ \
/ / / / |/ / /_/ /
/ /_/ / /| / _, _/
/_____/_/ |_/_/ |_|
It's a simple way to resolve the Docker container name to its IP using an
internal nginx reverse proxy and the special .localhost domain.
When a container my_service is running, DNR will expose it as
http://my_service.localhost from your host machine (Linux, Mac or Windows),
without changing the host's hosts file or requiring a custom DNS server.
docker run --restart unless-stopped --detach --tty \
--volume /var/run/docker.sock:/var/run/docker.sock \
--group-add (stat -c '%g' /var/run/docker.sock) \
--publish 80:8080 \
--name dnr alexandreslp/docker-name-resolver
docker run --restart unless-stopped --detach --tty \
--volume /var/run/docker.sock:/var/run/docker.sock \
--group-add (stat -c '%g' /var/run/docker.sock) \
--publish 80:8080 \
--name dnr alexandreslp/docker-name-resolver
docker run --restart unless-stopped --detach --tty \
--volume //./pipe/docker_engine:/var/run/docker.sock \
--publish 80:8080 \
--name dnr alexandreslp/docker-name-resolver
After starting DNR, any running container will be connected to the DNR network and available as:
http://<container_name>.localhost
You can also see a simple HTML status page with all active routes at:
http://dnr.localhost/
And you can list the routes from the CLI with:
docker exec -it dnr ./dnr list
The list command prints only the fields that matter in a terminal:
CONTAINER: the route/container nameIP: the IP address in the DNR networkPORTS: one or more exposed ports, joined by | (example: 80 | 443)Sorting defaults to the same as the status table (container name ascending), and can be customized:
# Sort by container name (ascending/descending)
docker exec -it dnr ./dnr list --sort name --order asc
docker exec -it dnr ./dnr list --sort name --order desc
# Sort by IP (ascending/descending)
docker exec -it dnr ./dnr list --sort ip --order asc
docker exec -it dnr ./dnr list --sort ip --order desc
Name or service not known
sudo apt-get -y install nscd && sudo service nscd restartContent type
Image
Digest
sha256:5bb551288…
Size
28.5 MB
Last updated
6 months ago
docker pull alexandreslp/docker-name-resolver