QNAP Container Station部署Pi-hole的docker-compose配置报错求助
错误原因
你的配置核心问题是YAML缩进错误,qnet_dhcp属于services下的独立服务项,你错误将其缩进到了pihole服务的restart配置项的子层级下,导致YAML语法解析失败,所以报错指向第24行配置不合法。
修正点
- 将
qnet_dhcp服务的所有配置行的缩进回退,和pihole、qnet_static服务保持同级(同属于services下的一级子项) - 确保
pihole服务的restart: unless-stopped配置后没有多余的嵌套子项
修正后完整配置
version: '3' services: pihole: container_name: pihole image: pihole/pihole:latest ports: - "65003:53/tcp" - "65002:53/udp" - "65001:67/udp" - "65000:80/tcp" environment: TZ: 'Berlin' WEBPASSWORD: 'password' # Volumes store your data between container upgrades volumes: - './etc-pihole/:/etc/pihole/' - './etc-dnsmasq.d/:/etc/dnsmasq.d/' # Recommended but not required (DHCP needs NET_ADMIN) cap_add: - NET_ADMIN restart: unless-stopped qnet_dhcp: image: alpine command: ifconfig eth0 networks: - qnet-dhcp qnet_static: image: alpine command: ifconfig eth0 networks: qnet-static: ipv4_address: 192.168.178.2 networks: qnet-dhcp: driver: qnet ipam: driver: qnet options: iface: "eth0" qnet-static: driver: qnet ipam: driver: qnet options: iface: "eth0" config: - subnet: 192.168.178.0/24 gateway: 192.168.178.1
如果你的需求是给pihole本身配置qnet网络而不是额外启动两个alpine测试容器,直接把pihole服务下的networks配置项加上即可,不需要保留qnet_dhcp、qnet_static这两个测试服务。
内容的提问来源于stack exchange,提问作者Waldecker
相关产品推荐
相关产品推荐

