Repository navigation
Description
What you're trying to do
We run untrusted build steps (dependency restores of third-party projects) in containers on an --internal network. The only intended way out is a filtering HTTP proxy container attached to the same network. --internal removes the route to the outside, but the host still has an address on the bridge, and that address is the network's gateway. Any service on the host that listens on all addresses (0.0.0.0 / ::) is therefore reachable from the container through the gateway: a database, a development server, an admin endpoint.
This applies to Kiri as a Linux-host engine (kiri daemon on Linux or in a WSL 2 distro), where the bridge and its gateway address are in the host's network namespace.
Docker Engine 28.0 (API 1.48) closes this path with the bridge option com.docker.network.bridge.gateway_mode_ipv4=isolated (and gateway_mode_ipv6=isolated), allowed only on --internal networks: the bridge gets no address, so the host has none in the network (moby#49262). For IPv4 it is equivalent to --internal --opt com.docker.network.bridge.inhibit_ipv4=true, an older option. Kiri advertises API 1.47 and supports neither, so on Kiri there is no way to close that path without firewall rules of our own.
Minimal reproduction
# On the host: a listener on every address
python3 -m http.server 8099 --bind 0.0.0.0 &
docker network create --internal --ipv6=false isolated-test
docker run --rm --network isolated-test python:3.13-alpine python3 -c "
import socket
gateway = '.'.join(socket.gethostbyname(socket.gethostname()).split('.')[:3] + ['1'])
socket.create_connection((gateway, 8099), timeout=5)
print('reached the host through', gateway)"Then repeat the test with the option:
docker network create --internal --ipv6=false --opt com.docker.network.bridge.gateway_mode_ipv4=isolated isolated-test2
docker run --rm --network isolated-test2 python:3.13-alpine python3 -c "
import socket
gateway = '.'.join(socket.gethostbyname(socket.gethostname()).split('.')[:3] + ['1'])
socket.create_connection((gateway, 8099), timeout=5)
print('reached the host through', gateway)"Current behaviour
- Without the option, the container prints
reached the host through <gateway>and the host's listener logs the request. - With the option: from reading
main,checked_optionsincrates/kiri/src/daemon/network.rsrefuses onlycom.docker.network.bridge.name, and no code readsgateway_mode_ipv4orinhibit_ipv4. So the option is accepted and kept fornetwork inspect, and the bridge still gets the gateway address.
What you'd like Kiri to do
Support com.docker.network.bridge.gateway_mode_ipv4=isolated on --internal networks (and inhibit_ipv4, which Docker treats the same way there), or any equivalent that creates an internal bridge network without giving the host an IPv4 address on that bridge. With it:
- the network is created and containers on it still reach each other by name;
- a TCP connection from the container to the subnet's first address (the gateway without the option) fails (
Connection refused/Network unreachable) and the host's listener sees nothing.
Kiri's embedded DNS listens on the network's gateway address (#477, #642), while Docker's answers at 127.0.0.11 inside the container, so name resolution on such a network needs a listener that is not a host address on the bridge.
If the option is not going to be supported, a documented alternative with the same effect (an internal network whose bridge carries no host address) would be just as useful, together with an API or capability signal clients can check before relying on it.
Related:
- Setting to turn off host loopback access (host.docker.internal) for untrusted workloads such as CI #995 asks to turn off host loopback access through
host.docker.internalon macOS. This issue is about the gateway address of an internal network's bridge. - Support --cgroup-parent, bridge name option, enable_icc=false and user namespace remap for hosting multi-tenant apps Context #213, Docker network compatibility: bridge options and IPv4/IPv6 drivers #125 and fix(linux): enforce com.docker.network.bridge.enable_icc=false #1000 cover other bridge options (
com.docker.network.bridge.name,enable_icc) and bridge option compatibility in general.
Would you like to build it?
No, just suggesting it
Activity