# DHCP with docker-compose on v6

**URL:** <https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008>\
**Category:** docker\
**Created:** [February 25, 2025, 10:44pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008 "2025-02-25T22:44:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kisiel92](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/22d042/32.png) [@kisiel92](https://discourse.pi-hole.net/u/kisiel92)\
**Post date:** [February 25, 2025, 10:44pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/1 "2025-02-25T22:44:33Z")

</div>

Hi all,

I'm trying to get DHCP working on v6, but a bit confused about the docker DHCP recommendations here: [https://docs.pi-hole.net/docker/DHCP/](https://docs.pi-hole.net/docker/DHCP/)

The instructions state to remove all of the ports and add `network_mode: host`, but now there are a few lines in the docker compose example referring to

```auto
# Uncomment the below if using Pi-hole as your DHCP Server
#- "67:67/udp"

```

and

```auto
cap_add:
     # See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
     # Required if you are using Pi-hole as your DHCP server, else not needed
     - NET_ADMIN

```

What should the docker compose file look like for v6 to allow for DHCP? Is adding `network_mode: host` no longer necessary with the new compose file?

Thank you!

---

<div class="post-metadata">

**Author:** ![arphillips06](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/arphillips06/32/46336_2.png) [@arphillips06](https://discourse.pi-hole.net/u/arphillips06)\
**Post date:** [February 25, 2025, 10:49pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/2 "2025-02-25T22:49:20Z")

</div>

I'm using network\_mode as I don't run anything else on the ports (53, 67, 80, 443) and v6 is working fine. Both DHCP and DNS.

The relevant part of my compose looks like this.

```auto
services:
  pihole:
    network_mode: "host"
# ports:
      # DNS Ports
# - "53:53/tcp"
 # - "53:53/udp"
      # Default HTTP Port
# - "8081:80/tcp"
      # Default HTTPs Port. FTL will generate a self-signed certificate
# - "443:443/tcp"
      # Uncomment the below if using Pi-hole as your DHCP Server
# - "67:67/udp"

```

That was my interpretation of the docs, but I am far from a docker expert.

> and

> ```auto
> cap_add:
> # See https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
> # Required if you are using Pi-hole as your DHCP server, else not needed
> - NET_ADMIN
> 
> ```

This I've left in as well.

My understanding is that `network_mode: "host"` deals with the traffic on all ports, as if the docker container was the host. Primarily this is an easy solution for the broadcast traffic that is DHCP.

---

<div class="post-metadata">

**Author:** ![Ladrien](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/ladrien/32/39018_2.png) [@Ladrien](https://discourse.pi-hole.net/u/Ladrien)\
**Post date:** [February 25, 2025, 10:59pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/3 "2025-02-25T22:59:57Z")

</div>

> [@arphillips06](#):
>
> ```auto
> services:
> pihole:
> network_mode: "host"
> # ports:
> # DNS Ports
> # - "53:53/tcp"
> # - "53:53/udp"
> # Default HTTP Port
> # - "8081:80/tcp"
> # Default HTTPs Port. FTL will generate a self-signed certificate
> # - "443:443/tcp"
> # Uncomment the below if using Pi-hole as your DHCP Server
> # - "67:67/udp"
> 
> ```

You'll want to uncomment all of those bindings.

> My understanding is that `network_mode: "host"` deals with the traffic on all ports, as if the docker container was the host. Primarily this is an easy solution for the broadcast traffic that is DHCP.

Exactly. With a bridged docker network, you may have to find a way to forward DHCP requests into the container due to the limitations of subnet broadcast traffic.

---

<div class="post-metadata">

**Author:** ![kisiel92](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/22d042/32.png) [@kisiel92](https://discourse.pi-hole.net/u/kisiel92)\
**Post date:** [February 25, 2025, 11:19pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/4 "2025-02-25T23:19:11Z")

</div>

Thank you both for your quick replies!

Ended up appending the line in the documentation and the DHCP server is working as intended. The beginning of my docker compose looks like:

```auto
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    network_mode: "host"
    ports:
      # DNS Ports
      - "53:53/tcp"
      - "53:53/udp"
      # Default HTTP Port
      - "80:80/tcp"
      # Default HTTPs Port. FTL will generate a self-signed certificate
      - "443:443/tcp"
      # Uncomment the below if using Pi-hole as your DHCP Server
      - "67:67/udp"

```

Hopefully getting the ipv6 DHCP will be easy to get running when I flash OpenWRT on my router in the next few weeks

---

<div class="post-metadata">

**Author:** ![Bucking\_Horn](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/bucking_horn/32/18719_2.png) [@Bucking\_Horn](https://discourse.pi-hole.net/u/Bucking_Horn)\
**Post date:** [February 25, 2025, 11:23pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/5 "2025-02-25T23:23:21Z")

</div>

> [@Ladrien](#):
>
> You'll want to uncomment all of those bindings.

Not in host network mode:

> [@kisiel92](#):
>
> The instructions state to remove all of the ports and add `network_mode: host`

In host network mode, the container's exposed ports are shared with the host directly, so there is no need to publish any ports in host mode.  
Docker will ignore them if present.

Declaring port 67 may be necessary in certain other scenarios, e.g. if your router would support relaying DHCP requests to another DHCP server and your Pi-hole container would run in bridge network mode.

---

<div class="post-metadata">

**Author:** ![Ladrien](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/ladrien/32/39018_2.png) [@Ladrien](https://discourse.pi-hole.net/u/Ladrien)\
**Post date:** [February 25, 2025, 11:28pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/6 "2025-02-25T23:28:38Z")

</div>

> [@kisiel92](#):
>
> Hopefully getting the ipv6 DHCP will be easy to get running when I flash OpenWRT on my router in the next few weeks

OpenWRT is sweet. I think you'll like it.

> [@Bucking\_Horn](#):
>
> > [@Ladrien](#):
> >
> > You'll want to uncomment all of those bindings.
> 
> Not in host network mode:

Thanks @Bucking_Horn. I've always left mine in.

---

<div class="post-metadata">

**Author:** ![arphillips06](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/arphillips06/32/46336_2.png) [@arphillips06](https://discourse.pi-hole.net/u/arphillips06)\
**Post date:** [February 25, 2025, 11:32pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/7 "2025-02-25T23:32:13Z")

</div>

Agree on WRT 😃

Yeah so I had to go double check to make sure I'd understood the docs. Like Bucking\_Horn said it ignores it.

```auto
ubuntu@pihole:~/piholedocker$ docker compose up -d
[+] Running 2/2
 ✔ Container pihole1 Started 4.6s
 ! pihole Published ports are discarded when using host network mode 0.0s
ubuntu@pihole:~/piholedocker$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
df69f979fc5f pihole/pihole:latest "start.sh" 14 seconds ago Up 9 seconds (health: starting) pihole1

```

It does mean that if I need other services then I'll need to put in a different solution i.e. a DHCP relay server. But that feels too much like my day job!

---

<div class="post-metadata">

**Author:** ![arphillips06](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/arphillips06/32/46336_2.png) [@arphillips06](https://discourse.pi-hole.net/u/arphillips06)\
**Post date:** [February 25, 2025, 11:34pm UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/8 "2025-02-25T23:34:45Z")

</div>

Nice one, as mentioned already the ports can be removed, commented out as they are ignored. DHCPv6 should be super simple from here, just turn it on in the GUI.

I've set mine up this evening and everything works as expected. Devices are completing the DORA and SARR processes and using v4 and v6 for DNS requests 🙂

---

<div class="post-metadata">

**Author:** ![kisiel92](https://discourse-cdn.pi-hole.net/letter_avatar_proxy/v4/letter/k/22d042/32.png) [@kisiel92](https://discourse.pi-hole.net/u/kisiel92)\
**Post date:** [February 26, 2025, 1:47am UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/9 "2025-02-26T01:47:11Z")

</div>

> [@Bucking\_Horn](#):
>
> > [@kisiel92](#):
> >
> > The instructions state to remove all of the ports and add `network_mode: host`
> 
> In host network mode, the container's exposed ports are shared with the host directly, so there is no need to publish any ports in host mode.  
> Docker will ignore them if present.
> 
> Declaring port 67 may be necessary in certain other scenarios, e.g. if your router would support relaying DHCP requests to another DHCP server and your Pi-hole container would run in bridge network mode.

I just want to confirm: As I understand it, for the most basic scenarios (i.e. appending `network_mode: "host"`, recomposing, enabling the DHCP server in settings, and disabling DHCP on the router), declaring port 67 will be ignored just like all the other declared ports when in host network mode. Is that correct?

---

<div class="post-metadata">

**Author:** ![Bucking\_Horn](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/bucking_horn/32/18719_2.png) [@Bucking\_Horn](https://discourse.pi-hole.net/u/Bucking_Horn)\
**Post date:** [February 26, 2025, 7:13am UTC](https://discourse.pi-hole.net/t/dhcp-with-docker-compose-on-v6/77008/10 "2025-02-26T07:13:07Z")

</div>

Your router's or any other DHCP server's configuration has zero impact on how Docker treats port assignments.

When using its host network mode, Docker will ignore any published ports.
