{"id":20838559,"url":"https://github.com/glorpen/docker-hostdns","last_synced_at":"2025-05-08T20:51:11.962Z","repository":{"id":57423319,"uuid":"86806126","full_name":"glorpen/docker-hostdns","owner":"glorpen","description":"Update BIND nameserver with Docker host names","archived":false,"fork":false,"pushed_at":"2019-07-15T08:23:00.000Z","size":70,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-16T02:19:23.172Z","etag":null,"topics":["bind","dns","docker","dynamic"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glorpen.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-31T10:10:27.000Z","updated_at":"2024-01-03T14:14:43.000Z","dependencies_parsed_at":"2022-09-05T11:10:52.833Z","dependency_job_id":null,"html_url":"https://github.com/glorpen/docker-hostdns","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glorpen%2Fdocker-hostdns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glorpen%2Fdocker-hostdns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glorpen%2Fdocker-hostdns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glorpen%2Fdocker-hostdns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glorpen","download_url":"https://codeload.github.com/glorpen/docker-hostdns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149326,"owners_count":21861717,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bind","dns","docker","dynamic"],"created_at":"2024-11-18T01:10:41.285Z","updated_at":"2025-05-08T20:51:11.942Z","avatar_url":"https://github.com/glorpen.png","language":"Python","readme":"==============\nDocker HostDNS\n==============\n\nUpdate BIND nameserver zone with Docker hosts via DNS Updates.\n\nUsage\n=====\n\n*Docker HostDNS* can be run by ``docker-hostdns`` wrapper script or directly with ``python -m docker_hostdns``.\n\n.. sourcecode::\n\n   usage: docker-entrypoint [-h] [--zone ZONE] [--dns-server DNS_SERVER]\n                            [--dns-key-secret DNS_KEY_SECRET]\n                            [--dns-key-name DNS_KEY_NAME]\n                            [--dns-key-alg {...}]\n                            [--name NAME] [--network NETWORK] [--verbose]\n                            [--syslog [SYSLOG]] [--clear-on-exit]\n\n   Update BIND nameserver zone with Docker hosts via DNS Updates.\n\n   optional arguments:\n     -h, --help            show this help message and exit\n     --zone ZONE           dns zone to update, defaults to \"docker\"\n     --dns-server DNS_SERVER\n                           address of DNS server which will be updated, defaults\n                           to 127.0.0.1\n     --dns-key-secret DNS_KEY_SECRET\n                           DNS Server key secret for use when updating zone, use\n                           '-' to read from stdin\n     --dns-key-name DNS_KEY_NAME\n                           DNS Server key name for use when updating zone\n     --dns-key-alg {...}\n                           DNS Server key algorithm for use when updating zone\n     --name NAME           name to differentiate between multiple instances\n                           inside same dns zone, defaults to current hostname\n     --network NETWORK     network to fetch container names from, defaults to\n                           docker default bridge, can be used multiple times\n     --verbose, -v         give more output - option is additive, and can be used\n                           up to 3 times\n     --syslog [SYSLOG]     enable logging to syslog, defaults to \"/dev/log\", you\n                           can provide path to unix socket or uri:\n                           \u003ctcp|udp|unix\u003e://\u003cpath_or_host\u003e[:\u003cport\u003e]\n     --clear-on-exit       clear zone on exit\n\n\nThe ``--daemonize`` options is only available when you have installed ``python-daemon3`` package.\n\nExample ``named.conf`` zone configuration with key auth:\n\n.. sourcecode::\n\n   include \"/etc/bind/docker.key\";\n\n   zone \"docker\" in {\n       type master;\n       file \"/var/bind/dyn/docker.zone\";\n       allow-update {\n         key \"docker-key\";\n       };\n   };\n\n``docker.key`` can be generated by:\n\n.. sourcecode:: sh\n\n   rndc-confgen -a -c docker.key -k docker-key\n\nAnd then:\n\n.. sourcecode:: sh\n\n   echo 'my base64 key secret' | docker-hostdns --dns-key-name docker-key --dns-key-secret -\n\nHost names\n==========\n\nHost name is created by using container name and slugifying \u0026 trimming it. So ``/example2::docker`` will result with ``example2-docker``.\nIn case of name duplication a \"-\u003cnumber\u003e\" will be appended, resulting with eg. ``example2-docker-1``\n\nFollowing dns records are created for each container, given ``example`` hostname and ``docker`` zone:\n\n- IPv4: ``example.docker``\n- IPv4: ``*.example.docker``\n- IPv6: ``example.docker``\n- IPv6: ``*.example.docker``\n- TXT: ``_container_\u003cname\u003e.docker`` with container name as value and instance name as ``\u003cname\u003e``\n\nTXT record is used for keeping track of added hosts so when app is stopped or resumed it keeps its state.\n\nCustom host names\n*****************\n\nYou can set custom host name by using container label ``pl.glorpen.hostname``, its content will be used as container name.\n\nDocker Image\n============\n\nDocker image is available at ``glorpen/hostdns``.\nFor help try ``docker run --rm -it glorpen/hostdns:latest --help``.\n\nRemember to mount ``/run/docker.sock`` inside container.\n\nBuild image from GitHub\n***********************\n\n- ``git clone \u003crepo\u003e``\n- ``cd docker-hostdns/``\n- ``docker build -t \"\u003cimage name\u003e\" .``\n\nDocker environment variables\n****************************\n\n- ``DNS_SERVER``:            address of DNS server which will be updated, defaults to ``127.0.0.1``\n- ``DNS_ZONE``:              DNS zone to update, defaults to ``docker``\n- ``DNS_KEY_NAME``:          DNS Server key name for use when updating zone\n- ``DNS_KEY_SECRET``:        DNS Server key secret for use when updating zone\n- ``DNS_KEY_SECRET_FILE``:   path of file with secret as its content\n- ``DNS_KEY_ALGORITHM``:     DNS Server key algorithm for use when updating zone\n- ``NAME``:                  name to differentiate between multiple instances inside same dns zone, defaults to current hostname\n- ``NETWORK``:               network to fetch container names from, defaults to docker default bridge, accepts multiple networks as comma delimited list (e.g. ``network1,network2,network3,..``)\n- ``VERBOSITY``:             give more output, accepts ``0`` to ``3``, defaults to ``0`` (equivalent to ``-v``, ``-vv``, ``-vvv`` arguments on the command line)\n- ``SYSLOG``:                enable logging to syslog, if set ``true`` or ``yes`` defaults to \"/dev/log\", or you can provide path to unix socket or uri: ``\u003ctcp|udp|unix\u003e://\u003cpath_or_host\u003e[:\u003cport\u003e]``\n- ``CLEAR_ON_EXIT``:         clear zone on exit, defaults to ``false`` (accepts ``true`` or ``yes``)\n\nSecuring DNS secret key\n***********************\n\nTo secure secret key (the ``dns-key-secret`` option) you can:\n\n- passing its contents to env var ``DNS_KEY_SECRET``\n- setting env var ``DNS_KEY_SECRET_FILE`` to path of file with secret as its content\n\nOption ``--dns-key-secret -`` will be then automatically prepended and secret key piped to docker-hostdns process.\n\nWorking with docker-compose\n===========================\n\nWhen using *docker-compose* for development you can create custom docker network and use it as\ndomain names source.\n\nTo do this, create docker network with ``docker network create example-dns`` and then run *Docker HostDNS* with ``--network example-dns`` argument.\n\nNext, with example ``docker-compose.yml``:\n\n.. sourcecode:: yaml\n\n   version: '2.2'\n   services:\n     app:\n       image: example\n       labels:\n         pl.glorpen.hostname: example\n       networks:\n         default: ~\n         dns: ~\n\n   networks:\n     dns:\n       external: true\n       name: example-dns\n\nyou can start container that would be accessible by host as ``example.docker`` domain.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglorpen%2Fdocker-hostdns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglorpen%2Fdocker-hostdns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglorpen%2Fdocker-hostdns/lists"}