Pi-hole Running Docker Desktop on MacOSX: Network Mode: host Not Filtering

Abstract: Fix Pi-hole DNS filtering failure on macOS Docker Desktop by switching from host to bridge networking and configuring system DNS.

Created: 2026-09-03 by
The issue occurs because Docker Desktop on macOS runs a Linux VM, and the host network mode binds to the VM’s internal IP rather than your Mac’s local interface. To restore DNS filtering, you must switch to bridge networking or configure static IPs correctly within the compose file so Pi-hole resolves queries from your host machine properly.

Understanding the Network Isolation

When you use network_mode: host in a Docker Compose configuration, the container shares the network stack of the daemon running it. On native Linux systems, this means sharing the host's network interface directly. However, Docker Desktop for macOS operates differently. It does not run directly on the kernel; instead, it runs a lightweight Linux virtual machine (VM) using HyperKit or Apple Virtualization Framework.

In this architecture, the "host" network is actually the network namespace of that internal Linux VM. When Pi-hole binds to 0.0.0.0 or localhost within that VM, it is listening on the VM's internal loopback or virtual interfaces. Your macOS host cannot reach these services via 127.0.0.1 unless specific port forwarding rules are explicitly configured in Docker Desktop settings, which often fails for DNS traffic due to how macOS handles system-level DNS resolution.

The Recommended Solution: Bridge Networking

The most robust way to solve this is to remove network_mode: host and rely on the default bridge network. This allows Docker to manage IP assignment and port mapping automatically. You need to modify your docker-compose.yml file to expose the DNS port (53) to the host.

First, locate your docker-compose.yml file for the Pi-hole service. Remove any lines containing network_mode: host. Then, ensure the ports are mapped correctly. The standard configuration requires mapping UDP port 53 to the host, as DNS primarily uses UDP.

version: '3'
services:
  pihole:
    image: pihole/pihole:latest
    container_name: pihole
    restart: always
    ports:
      - "53:53/udp"
      - "53:53/tcp"
      - "80:80/tcp"
      - "443:443/tcp"
    environment:
      TZ: 'America/New_York'
      WEBPASSWORD: 'your_secure_password'
    volumes:
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'

After saving the file, restart the container using docker-compose down && docker-compose up -d. Docker will assign an internal IP address to the container, typically something like 172.18.0.2. You can verify this by running docker inspect pihole --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'.

Configuring macOS DNS Resolution

Once the container is running on the bridge network, you must tell macOS to send DNS queries to the Pi-hole container's IP address. Go to System Preferences > Network. Select your active connection (Wi-Fi or Ethernet) and click Advanced. Navigate to the DNS tab.

Add the IP address of your Pi-hole container to the list of DNS servers. Move it to the top of the list to ensure it takes precedence. Click OK and apply the changes. You may need to renew the DHCP lease or toggle Wi-Fi off and on to clear the cache.

If you prefer not to change system-wide DNS settings, you can create a local resolver configuration. Create a file at /etc/resolver/local with the following content:

domain local
nameserver 172.18.0.2

This approach directs all queries for the .local domain to your Pi-hole instance without affecting other internet traffic. Replace 172.18.0.2 with the actual IP assigned to your container. Note that if you restart the container frequently, the IP might change unless you define a custom network with static IPs.

Static IP Configuration for Stability

To prevent IP changes after container restarts, define a custom bridge network in your docker-compose.yml. This ensures Pi-hole always gets the same IP address, making your DNS configuration stable.

version: '3'
networks:
  pihole-net:
    driver: bridge
    ipam:
      config:
        - subnet: 172.20.0.0/24

services:
  pihole:
    image: pihole/pihole:latest
    networks:
      pihole-net:
        ipv4_address: 172.20.0.5
    ports:
      - "53:53/udp"
      - "53:53/tcp"
      - "80:80/tcp"
      - "443:443/tcp"

With this setup, your macOS DNS server should always point to 172.20.0.5. This method is particularly useful if you have multiple containers or complex networking requirements. It also aligns with best practices for container orchestration, ensuring predictable behavior across reboots.

Verifying Functionality

After applying these changes, verify that Pi-hole is filtering correctly. Open Terminal on macOS and run dig @172.20.0.5 example.com. If you receive a response from the Pi-hole IP and see the query being logged in the Pi-hole web interface, the setup is successful. You can also check the admin dashboard to view blocked ads and queried domains.

If you encounter issues, ensure that no other local DNS services, such as mDNSResponder, are interfering. You can flush the DNS cache on macOS by running dscacheutil -flushcache; sudo killall -HUP mDNSResponder. This forces the system to re-query the new DNS server immediately.

Frequently Asked Questions

Why did my Pi-hole stop working after a Docker update?

Docker updates sometimes reset network configurations or change default bridge subnets. Always check your container's IP address after an update using docker inspect and update your macOS DNS settings accordingly. Using static IPs in a custom network prevents this drift entirely.

Can I use host network mode with port forwarding?

While technically possible, configuring explicit port forwarding for DNS over UDP in Docker Desktop on macOS is notoriously difficult and often unreliable. Switching to bridge networking is significantly more stable and easier to maintain long-term.

How do I handle IPv6 with Pi-hole on Docker?

Pi-hole supports IPv6, but macOS DNS handling for IPv6 can be complex. Ensure your router advertises IPv6 prefixes correctly and that your Pi-hole container has an IPv6 address assigned. You may need to add the IPv6 address to your macOS DNS servers manually if automatic discovery fails.

What if I want to use Pi-hole only for specific apps?

You can achieve this by using split DNS configurations as described earlier with the /etc/resolver/ directory. This allows you to route only certain domains through Pi-hole while leaving general internet traffic unaffected, providing granular control over your network security.

Is there a risk of DNS loops when using bridge networks?

Yes, if your macOS host tries to resolve the Pi-hole container's IP via itself, it can create a loop. Always ensure your macOS DNS server points directly to the container's IP, not to localhost or the gateway IP, to avoid circular dependencies.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More