You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 00:15:03