提供PowerDNS相关Docker镜像,包括带MySQL/PostgreSQL后端的权威服务器、递归器及管理界面,均支持通过环境变量完全配置,自动初始化数据库,适用于DNS服务部署与管理。
PowerDNS Docker镜像
本仓库包含以下Docker镜像:pdns-mysql、pdns-pgsql、pdns-recursor和pdns-admin。pdns-mysql镜像包含可完全配置的https://doc.powerdns.com/authoritative/(带MySQL后端,不含MySQL服务器)。**pdns-pgsql**镜像包含可完全配置的https://doc.powerdns.com/authoritative/(带PostgreSQL后端,不含PostgreSQL服务器)。**pdns-recursor**镜像包含可完全配置的https://doc.powerdns.com/recursor/。**pdns-admin**镜像包含https://github.com/PowerDNS-Admin/PowerDNS-Admin web应用的前端(Caddy)和后端(uWSGI),该应用基于Flask开发,用于管理PowerDNS服务器。
pdns-mysql、pdns-pgsql和pdns-recursor镜像还提供alpine标签(感谢@PoppyPop)。
所有镜像均在Docker Hub可用:
- https://hub.docker.com/r/pschiffe/pdns-mysql/
- https://hub.docker.com/r/pschiffe/pdns-pgsql/
- https://hub.docker.com/r/pschiffe/pdns-recursor/
- https://hub.docker.com/r/pschiffe/pdns-admin/
源代码GitHub仓库:https://github.com/pschiffe/docker-pdns
pdns-mysql
https://hub.docker.com/r/pschiffe/pdns-mysql/
概述
包含PowerDNS 4.x权威服务器及MySQL后端(需外部MySQL服务器)。支持通过环境变量配置数据库连接及PowerDNS服务,自动初始化缺失的数据库表。
配置说明
数据库连接配置
通过以下环境变量配置MySQL连接(默认值如下):
PDNS_gmysql_host=mysql PDNS_gmysql_port=3306 PDNS_gmysql_user=root PDNS_gmysql_password=powerdns PDNS_gmysql_dbname=powerdns
若与官方https://hub.docker.com/_/mariadb/镜像以别名`mysql`链接,上述变量可自动配置,无需手动指定。
PowerDNS服务配置
PowerDNS通过环境变量配置:所有以PDNS_为前缀的变量会被处理并写入/etc/pdns/pdns.conf,规则为:去除PDNS_前缀,将_替换为-。例如,PDNS_gmysql_host=mysql会转换为gmysql-host=mysql。
超级主服务器配置
支持SUPERMASTER_IPS环境变量,用于配置从DNS服务器的超级主服务器(https://doc.powerdns.com/authoritative/modes-of-operation.html#autoprimary-automatic-provisioning-of-secondaries),支持空格分隔的多个IP地址。
所有可用设置
详见https://doc.powerdns.com/authoritative/settings.html。
使用示例
启用API的主服务器(含从服务器配置)
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-master \ --hostname ns1.example.com --link mariadb:mysql \ -e PDNS_master=yes \ -e PDNS_api=yes \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ -e PDNS_webserver_address=0.0.0.0 \ -e PDNS_webserver_password=secret2 \ -e PDNS_version_string=anonymous \ -e PDNS_default_ttl=1500 \ -e PDNS_allow_axfr_ips=172.5.0.21 \ -e PDNS_only_notify=172.5.0.21 \ docker.xuanyuan.run/pschiffe/pdns-mysql
带超级主服务器的从服务器
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ --hostname ns2.example.com --link mariadb:mysql \ -e PDNS_gmysql_dbname=powerdnsslave \ -e PDNS_slave=yes \ -e PDNS_version_string=anonymous \ -e PDNS_disable_axfr=yes \ -e PDNS_allow_notify_from=172.5.0.20 \ -e SUPERMASTER_IPS=172.5.0.20 \ docker.xuanyuan.run/pschiffe/pdns-mysql
pdns-pgsql
https://hub.docker.com/r/pschiffe/pdns-pgsql/
概述
包含PowerDNS 4.x权威服务器及PostgreSQL后端(需外部PostgreSQL服务器)。支持通过环境变量配置数据库连接及PowerDNS服务,自动初始化缺失的数据库表。
配置说明
数据库连接配置
通过以下环境变量配置PostgreSQL连接(默认值如下):
PDNS_gpgsql_host=pgsql PDNS_gpgsql_port=5432 PDNS_gpgsql_user=postgres PDNS_gpgsql_password=powerdns PDNS_gpgsql_dbname=powerdns
若与官方https://hub.docker.com/_/postgres镜像以别名`pgsql`链接,上述变量可自动配置,无需手动指定。
PowerDNS服务配置
与pdns-mysql相同,通过PDNS_前缀环境变量配置,变量转换规则一致。
超级主服务器配置
支持SUPERMASTER_IPS环境变量,用法同pdns-mysql。
所有可用设置
详见https://doc.powerdns.com/authoritative/settings.html。
使用示例
启用API的主服务器(含从服务器配置)
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-master \ --hostname ns1.example.com --link postgres:pgsql \ -e PDNS_master=yes \ -e PDNS_api=yes \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ -e PDNS_webserver_address=0.0.0.0 \ -e PDNS_webserver_password=secret2 \ -e PDNS_version_string=anonymous \ -e PDNS_default_ttl=1500 \ -e PDNS_allow_axfr_ips=172.5.0.21 \ -e PDNS_only_notify=172.5.0.21 \ docker.xuanyuan.run/pschiffe/pdns-pgsql
带超级主服务器的从服务器
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ --hostname ns2.example.com --link postgres:pgsql \ -e PDNS_gpgsql_dbname=powerdnsslave \ -e PDNS_slave=yes \ -e PDNS_version_string=anonymous \ -e PDNS_disable_axfr=yes \ -e PDNS_allow_notify_from=172.5.0.20 \ -e SUPERMASTER_IPS=172.5.0.20 \ docker.xuanyuan.run/pschiffe/pdns-pgsql
pdns-recursor
https://hub.docker.com/r/pschiffe/pdns-recursor/
概述
包含可完全配置的PowerDNS 4.x递归器,支持通过环境变量自定义配置。
配置说明
通过PDNS_前缀环境变量配置,变量会被写入/etc/pdns/recursor.conf,转换规则为:去除PDNS_前缀,_替换为-。例如,PDNS_api_key=secret会转换为api-key=secret。
所有可用设置详见https://doc.powerdns.com/recursor/settings.html。
使用示例
启用API的递归器
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-recursor \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ -e PDNS_webserver_address=0.0.0.0 \ -e PDNS_webserver_password=secret2 \ docker.xuanyuan.run/pschiffe/pdns-recursor
pdns-admin
https://hub.docker.com/r/pschiffe/pdns-admin/
概述
包含https://github.com/PowerDNS-Admin/PowerDNS-Admin web应用(基于Flask开发),用于管理PowerDNS服务器。需外部MySQL或PostgreSQL服务器,包含Caddy前端(处理静态文件及HTTPS)和uWSGI后端。
配置说明
数据库连接配置
MySQL配置
PDNS_ADMIN_SQLA_DB_HOST=mysql PDNS_ADMIN_SQLA_DB_PORT=3306 PDNS_ADMIN_SQLA_DB_USER=root PDNS_ADMIN_SQLA_DB_PASSWORD=powerdnsadmin PDNS_ADMIN_SQLA_DB_NAME=powerdnsadmin
与官方https://hub.docker.com/_/mariadb/镜像以别名`mysql`链接时,自动配置连接。
PostgreSQL配置
PDNS_ADMIN_SQLA_DB_TYPE=postgres PDNS_ADMIN_SQLA_DB_HOST=pgsql PDNS_ADMIN_SQLA_DB_PORT=5432 PDNS_ADMIN_SQLA_DB_USER=postgres PDNS_ADMIN_SQLA_DB_PASSWORD=powerdnsadmin PDNS_ADMIN_SQLA_DB_NAME=powerdnsadmin
数据库表缺失时会自动初始化。
应用配置
通过PDNS_ADMIN_前缀环境变量配置,变量会写入/opt/powerdns-admin/powerdnsadmin/default_config.py。
连接PowerDNS服务器
需PowerDNS服务器启用API(示例配置):
api=yes api-key=secret webserver=yes webserver-address=0.0.0.0 webserver-allow-from=172.5.0.0/16
通过以下环境变量配置连接:
PDNS_API_URL="http://pdns:8081/" PDNS_API_KEY="" PDNS_VERSION=""
与本仓库的pdns-mysql镜像以别名pdns链接时,自动配置连接,无需手动指定上述变量。
API密钥与SALT
需通过PDNS_ADMIN_SALT环境变量指定SALT(用于生成API密钥),可通过以下命令生成:
bashpython3 -c 'import bcrypt; print(bcrypt.gensalt().decode("utf-8"));'
示例值:$2b$12$xxxxxxxxxxxxxxxxxxxxxx(使用docker-compose时,`# PowerDNS Docker镜像
本仓库包含以下Docker镜像:pdns-mysql、pdns-pgsql、pdns-recursor和pdns-admin。pdns-mysql镜像包含可完全配置的https://doc.powerdns.com/authoritative/(带MySQL后端,不含MySQL服务器)。**pdns-pgsql**镜像包含可完全配置的https://doc.powerdns.com/authoritative/(带PostgreSQL后端,不含PostgreSQL服务器)。**pdns-recursor**镜像包含可完全配置的https://doc.powerdns.com/recursor/。**pdns-admin**镜像包含https://github.com/PowerDNS-Admin/PowerDNS-Admin web应用的前端(Caddy)和后端(uWSGI),该应用基于Flask开发,用于管理PowerDNS服务器。
pdns-mysql、pdns-pgsql和pdns-recursor镜像还提供alpine标签(感谢@PoppyPop)。
所有镜像均在Docker Hub可用:
- https://hub.docker.com/r/pschiffe/pdns-mysql/
- https://hub.docker.com/r/pschiffe/pdns-pgsql/
- https://hub.docker.com/r/pschiffe/pdns-recursor/
- https://hub.docker.com/r/pschiffe/pdns-admin/
源代码GitHub仓库:https://github.com/pschiffe/docker-pdns
pdns-mysql
https://hub.docker.com/r/pschiffe/pdns-mysql/
概述
包含PowerDNS 4.x权威服务器及MySQL后端(需外部MySQL服务器)。支持通过环境变量配置数据库连接及PowerDNS服务,自动初始化缺失的数据库表。
配置说明
数据库连接配置
通过以下环境变量配置MySQL连接(默认值如下):
PDNS_gmysql_host=mysql PDNS_gmysql_port=3306 PDNS_gmysql_user=root PDNS_gmysql_password=powerdns PDNS_gmysql_dbname=powerdns
若与官方https://hub.docker.com/_/mariadb/镜像以别名`mysql`链接,上述变量可自动配置,无需手动指定。
PowerDNS服务配置
PowerDNS通过环境变量配置:所有以PDNS_为前缀的变量会被处理并写入/etc/pdns/pdns.conf,规则为:去除PDNS_前缀,将_替换为-。例如,PDNS_gmysql_host=mysql会转换为gmysql-host=mysql。
超级主服务器配置
支持SUPERMASTER_IPS环境变量,用于配置从DNS服务器的超级主服务器(https://doc.powerdns.com/authoritative/modes-of-operation.html#autoprimary-automatic-provisioning-of-secondaries),支持空格分隔的多个IP地址。
所有可用设置
详见https://doc.powerdns.com/authoritative/settings.html。
使用示例
启用API的主服务器(含从服务器配置)
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-master \ --hostname ns1.example.com --link mariadb:mysql \ -e PDNS_master=yes \ -e PDNS_api=yes \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ -e PDNS_webserver_address=0.0.0.0 \ -e PDNS_webserver_password=secret2 \ -e PDNS_version_string=anonymous \ -e PDNS_default_ttl=1500 \ -e PDNS_allow_axfr_ips=172.5.0.21 \ -e PDNS_only_notify=172.5.0.21 \ docker.xuanyuan.run/pschiffe/pdns-mysql
带超级主服务器的从服务器
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ --hostname ns2.example.com --link mariadb:mysql \ -e PDNS_gmysql_dbname=powerdnsslave \ -e PDNS_slave=yes \ -e PDNS_version_string=anonymous \ -e PDNS_disable_axfr=yes \ -e PDNS_allow_notify_from=172.5.0.20 \ -e SUPERMASTER_IPS=172.5.0.20 \ docker.xuanyuan.run/pschiffe/pdns-mysql
pdns-pgsql
https://hub.docker.com/r/pschiffe/pdns-pgsql/
概述
包含PowerDNS 4.x权威服务器及PostgreSQL后端(需外部PostgreSQL服务器)。支持通过环境变量配置数据库连接及PowerDNS服务,自动初始化缺失的数据库表。
配置说明
数据库连接配置
通过以下环境变量配置PostgreSQL连接(默认值如下):
PDNS_gpgsql_host=pgsql PDNS_gpgsql_port=5432 PDNS_gpgsql_user=postgres PDNS_gpgsql_password=powerdns PDNS_gpgsql_dbname=powerdns
若与官方https://hub.docker.com/_/postgres镜像以别名`pgsql`链接,上述变量可自动配置,无需手动指定。
PowerDNS服务配置
与pdns-mysql相同,通过PDNS_前缀环境变量配置,变量转换规则一致。
超级主服务器配置
支持SUPERMASTER_IPS环境变量,用法同pdns-mysql。
所有可用设置
详见https://doc.powerdns.com/authoritative/settings.html。
使用示例
启用API的主服务器(含从服务器配置)
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-master \ --hostname ns1.example.com --link postgres:pgsql \ -e PDNS_master=yes \ -e PDNS_api=yes \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ -e PDNS_webserver_address=0.0.0.0 \ -e PDNS_webserver_password=secret2 \ -e PDNS_version_string=anonymous \ -e PDNS_default_ttl=1500 \ -e PDNS_allow_axfr_ips=172.5.0.21 \ -e PDNS_only_notify=172.5.0.21 \ docker.xuanyuan.run/pschiffe/pdns-pgsql
带超级主服务器的从服务器
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-slave \ --hostname ns2.example.com --link postgres:pgsql \ -e PDNS_gpgsql_dbname=powerdnsslave \ -e PDNS_slave=yes \ -e PDNS_version_string=anonymous \ -e PDNS_disable_axfr=yes \ -e PDNS_allow_notify_from=172.5.0.20 \ -e SUPERMASTER_IPS=172.5.0.20 \ docker.xuanyuan.run/pschiffe/pdns-pgsql
pdns-recursor
https://hub.docker.com/r/pschiffe/pdns-recursor/
概述
包含可完全配置的PowerDNS 4.x递归器,支持通过环境变量自定义配置。
配置说明
通过PDNS_前缀环境变量配置,变量会被写入/etc/pdns/recursor.conf,转换规则为:去除PDNS_前缀,_替换为-。例如,PDNS_api_key=secret会转换为api-key=secret。
所有可用设置详见https://doc.powerdns.com/recursor/settings.html。
使用示例
启用API的递归器
bashdocker run -d -p 53:53 -p 53:53/udp --name pdns-recursor \ -e PDNS_api_key=secret \ -e PDNS_webserver=yes \ -e PDNS_webserver_address=0.0.0.0 \ -e PDNS_webserver_password=secret2 \ docker.xuanyuan.run/pschiffe/pdns-recursor
pdns-admin
https://hub.docker.com/r/pschiffe/pdns-admin/
概述
包含https://github.com/PowerDNS-Admin/PowerDNS-Admin web应用(基于Flask开发),用于管理PowerDNS服务器。需外部MySQL或PostgreSQL服务器,包含Caddy前端(处理静态文件及HTTPS)和uWSGI后端。
配置说明
数据库连接配置
MySQL配置
PDNS_ADMIN_SQLA_DB_HOST=mysql PDNS_ADMIN_SQLA_DB_PORT=3306 PDNS_ADMIN_SQLA_DB_USER=root PDNS_ADMIN_SQLA_DB_PASSWORD=powerdnsadmin PDNS_ADMIN_SQLA_DB_NAME=powerdnsadmin
与官方https://hub.docker.com/_/mariadb/镜像以别名`mysql`链接时,自动配置连接。
PostgreSQL配置
PDNS_ADMIN_SQLA_DB_TYPE=postgres PDNS_ADMIN_SQLA_DB_HOST=pgsql PDNS_ADMIN_SQLA_DB_PORT=5432 PDNS_ADMIN_SQLA_DB_USER=postgres PDNS_ADMIN_SQLA_DB_PASSWORD=powerdnsadmin PDNS_ADMIN_SQLA_DB_NAME=powerdnsadmin
数据库表缺失时会自动初始化。
应用配置
通过PDNS_ADMIN_前缀环境变量配置,变量会写入/opt/powerdns-admin/powerdnsadmin/default_config.py。
连接PowerDNS服务器
需PowerDNS服务器启用API(示例配置):
api=yes api-key=secret webserver=yes webserver-address=0.0.0.0 webserver-allow-from=172.5.0.0/16
通过以下环境变量配置连接:
PDNS_API_URL="http://pdns:8081/" PDNS_API_KEY="" PDNS_VERSION=""
与本仓库的pdns-mysql镜像以别名pdns链接时,自动配置连接,无需手动指定上述变量。
API密钥与SALT
需通过PDNS_ADMIN_SALT环境变量指定SALT(用于生成API密钥),可通过以下命令生成:
bashpython3 -c 'import bcrypt; print(bcrypt.gensalt().decode("utf-8"));'
示例值:$2b$12$xxxxxxxxxxxxxxxxxxxxxx(使用docker-compose时,需转义为$)。
Let's Encrypt SSL配置
包含的Caddy服务器支持通过Let's Encrypt自动配置HTTPS:
SSL_MAIN_DOMAIN:HTTPS主域名SSL_EXTRA_DOMAINS:逗号分隔的额外域名(重定向至主域名)- 需暴露端口:
8080→80,8443→443(含UDP,用于HTTP/3) - 持久化目录:
/var/lib/caddy(存储证书)
持久化数据
用户上传目录需持久化:/opt/powerdns-admin/upload
使用示例
链接pdns-mysql和数据库
bashdocker run -d -p 8080:8080 --name pdns-admin \ --link mariadb:mysql --link pdns-master:pdns \ -v pdns-admin-upload:/opt/powerdns-admin/upload \ docker.xuanyuan.run/pschiffe/pdns-admin
启用HTTPS
bashdocker run -d -p 80:8080 -p 443:8443 -p 443:8443/udp --name pdns-admin \ --link mariadb:mysql --link pdns-master:pdns \ -v pdns-admin-caddy:/var/lib/caddy \ -v pdns-admin-upload:/opt/powerdns-admin/upload \ -e SSL_MAIN_DOMAIN=www.pdns-admin.com \ -e SSL_EXTRA_DOMAINS=pdns-admin.com,pdns-admin.eu \ docker.xuanyuan.run/pschiffe/pdns-admin
Docker Compose
提供示例docker-compose文件,可通过以下命令启动:
bashdocker-compose -f docker-compose-mysql.yml up -d
Ansible Playbook
提供Ansible playbook用于构建和运行容器:
bashansible-playbook ansible-playbook-mysql.yml
pschiffe 命名空间的其他可用镜像:
更多相关 Docker 镜像与资源
以下是 pschiffe/pdns-recursor 相关的常用 Docker 镜像,适用于 不同场景 等不同场景:
镜像拉取方式
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
轩辕镜像加速拉取命令点我查看更多 pdns-recursor 镜像标签
DockerHub 原生拉取命令
用户好评
来自真实用户的反馈,见证轩辕镜像的优质服务