yaml for pihole container on QNAP

1.1k Views Asked by At

I am trying to make the following docker-compose.yaml to run on my QNAP container station.

The following part is working, but after the "restart: unless-stopped" the mess begins.

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)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    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

I got the network information directly from QNAP https://qnap-dev.github.io/container-station-api/qnet.html and tried to verify it with http://www.yamllint.com/, but it does not work together. error line 24

notvalid

1

There are 1 best solutions below

0
On BEST ANSWER

One of your service names is not correctly indented.

Additionally, you have provided an invalid configuration for ipam for the version 3 file. You can only provide options in version 2 according to the docs.

I will truncate the file for brevity.

# you need file version 2 in order to use options in ipam
# the file you copied it from is also using version 2
version: '2'

services:
  pihole:
    ...
  # this one (qnet_dhcp) is the name of another service. 
  # In your original code the indention is incorrect.
  # It should be aligned with the other services.
  qnet_dhcp:
    ...
  qnet_static:
    ...

networks:
  qnet-dhcp:
    ...
    ipam:
      ...
      # as mentioned above,
      # this is only valid in version 2
      options:
        ...