~/t/g/unraid $

Docker connections failing? Check host or bridge mode

gist Choose a network from the connections your app needs. Check container names, listening ports and host bindings before changing modes.

contents
  1. Step 1: Compare the network modes
  2. Step 2: Test a request on the bridge
  3. Step 3: Match the address to the caller
  4. Step 4: Check discovery and dedicated-address needs
  5. Step 5: Change one service and check its callers
  6. Common questions

If Docker connections fail after switching between host and bridge networking, check which address and port each client now needs.

I run web apps, AdGuard Home and Homebridge on my Unraid box. Their network requirements differ. For a web app and database on one Docker host, a user-defined bridge is a practical starting point: it provides name resolution and keeps unrelated container groups separate. See Docker’s bridge documentation.

Step 1: Compare the network modes

Mode Address and ports When to consider it Main tradeoff
User-defined bridge Separate container address; selected ports can be published through the host Apps and databases that communicate on one Docker host Name resolution requires a shared network
Host networking Shares the host network namespace; no separate container address Apps whose instructions call for host networking Shares host ports and reduces network isolation
Dedicated LAN address with macvlan or ipvlan L2 Separate address on the configured LAN Services that need their own LAN address Requires address planning and checks for driver limits

A Docker bridge address is not automatically an address on your home LAN. On a user-defined bridge, containers resolve each other by name or alias and connect using container ports. They do not need published ports for those connections. The built-in network named bridge lacks that automatic name resolution. See Docker bridge networking.

In host mode, Docker discards -p and other publish options. A service listening on port 80 uses host port 80; 8080:80 cannot move it to 8080. Check that the required host port is available before switching. Docker’s host networking documentation states both behaviors.

In docker inspect output, check:

  • The container’s network mode.
  • The network’s driver.
  • The bridge container’s network membership and alias.
  • Any published host port needed by external clients.

Keep full inspect output private. It can include addresses, mounts and environment values.

The bridge has its own container membership; the host client uses the host network namespace
Two containers are members of the bridge and can find each other by name. The host-mode container is not on it at all.

Step 2: Test a request on the bridge

This test needs Linux Docker Engine, Docker Compose and access to pull two public images. Use a separate directory and an unused project name.

Save this as compose.yaml. The unprivileged NGINX image listens on port 8080 by default, as documented in its README. This configuration publishes no host ports.

services:
  server:
    image: nginxinc/nginx-unprivileged:stable-alpine
    networks:
      default:
        aliases:
          - server.example

Start the test with a fixed project name:

docker compose -p network-demo up -d

Inspect only the network driver and scope:

docker network inspect network-demo_default \
  --format 'driver={{.Driver}} scope={{.Scope}}'

Send an HTTP request from another container on that network:

docker run --rm \
  --network network-demo_default \
  curlimages/curl:latest \
  --fail --show-error --silent \
  http://server.example:8080/

Look for the web server’s welcome page. A successful response checks name resolution and HTTP access between these containers. Check LAN access separately if the service needs it.

Compose creates a project network by default. Services use their service names, aliases and container ports for internal connections. See networking in Compose.

If the request fails, check that the server started and both containers joined network-demo_default. The alias server.example belongs to this Docker network; it is not a public DNS record.

Remove the disposable project when finished:

docker compose -p network-demo down
A curl request reaches server.example on port 8080 from another container on the same bridge
From a second container, the alias and the container port (8080) are enough. No published port needed.
docker network inspect network-demo_default --format 'driver={{.Driver}} scope={{.Scope}}'
driver=bridge scope=local

The bridge driver confirms this network uses a separate container network rather than host mode.

Step 3: Match the address to the caller

Write down who needs to connect before changing a live service.

For a bridge service listening on container port 8080:

Caller Destination with ordinary bridge settings
Another container on the same user-defined bridge Service name or alias, port 8080
The Linux Docker host Container address and port, or a published host port
A LAN device Host LAN address and published port

The host can reach bridge container ports directly. Publishing provides a host address and port for clients outside that bridge. See Docker port publishing.

9090:8080 maps host port 9090 to container port 8080. A sibling container still uses port 8080.

Without a host address, Docker’s default is to publish on all host addresses. Network or daemon settings can change that default. See default host binding addresses.

For access from the host alone, bind the published port to 127.0.0.1. Docker documents an exception for releases older than 28.0.0: devices on the same network segment could reach ports published to localhost. Check the Engine release and binding before relying on that restriction. See port publishing and mapping.

Inside a bridge container, localhost points to that container. For a reverse proxy on a shared bridge, use the upstream’s service name and container port. Compose documents this distinction in its networking guide.

Separate Compose projects normally create separate networks. When services across projects need to communicate, attach them to an existing shared network marked external: true. Attach only the services that need those connections. See connecting multiple Compose projects.

Step 4: Check discovery and dedicated-address needs

Test LAN discovery separately from HTTP access. Opening a settings page checks a different connection from discovering an accessory.

The official Homebridge Docker README lists host networking as required for HomeKit discovery. Check each app’s instructions before applying the same choice elsewhere.

Host networking works on Linux Docker Engine. Docker Desktop 4.34 and later provides opt-in support for Linux containers. Desktop’s implementation works at layer 4 and does not support protocols below TCP or UDP. Check the app’s discovery requirements when moving between Desktop and Linux. See Docker Desktop host networking.

For a dedicated LAN address, check the driver and server settings. Macvlan containers cannot communicate directly with their host through the parent interface by default. Docker documents options for adding that connection in its macvlan guide.

Ipvlan has different modes and interface behavior. Review the ipvlan documentation before choosing it.

Step 5: Change one service and check its callers

Save the existing network settings and upstream addresses before editing them.

After changing one service:

  1. Confirm that it starts and listens on the intended port.
  2. Test a request from each container that depends on it.
  3. Test host or LAN access where required.
  4. Test discovery if the app uses it.

For a failed request, record the caller, destination name, destination port and error. Compare those details with Step 3 before making another change. Restore the saved settings if you need to recover access.

Common questions

Should I use host or bridge networking for Docker?

For web apps and databases on one host, start by considering a user-defined bridge. It provides container name resolution and separates unrelated groups. Use host mode when the app has a documented requirement, such as Homebridge’s discovery requirement. See the bridge documentation and Homebridge README.

Why does localhost fail in my reverse proxy container?

In bridge mode, it points to the proxy container itself. Use the upstream’s service name and container port on a shared network. See Compose networking.

Do containers need published ports to talk to each other?

No, when they share a user-defined bridge. They use container ports directly. See Docker bridge networking.

Why did my port mapping stop working in host mode?

Docker ignores published-port mappings in host mode. Connect to the application’s listening port on the host, or change the application’s configured port. See host networking.

Why can’t a container resolve a service in another Compose project?

The projects normally have separate networks. Attach the services to a shared external network when they need to communicate by name. See Compose networking across projects.

Should every container get its own LAN address?

No. First check whether its clients can use a published host port or a shared bridge. Docker’s macvlan documentation recommends considering bridge networking when the application can use it.

If an app connects but cannot read or write its files, check Docker file permissions. Related: Unraid and Docker guides.

../unraid/ every Unraid + Docker guide