12 Commits

Author SHA1 Message Date
Akihiro Suda
84aedb8055 rootless: support detach-netns mode
Now `dockerd-rootless.sh` launches RootlessKit with `--detach-netns`
so as to run the daemon in the host network namespace.

The libnetwork namespaces are allocated inside the "detached" netns
(`$ROOTLESSKIT_STATE_DIR/netns`) that is associated with slirp4netns,
vpnkit, pasta, etc., as the rootless daemon has no `CAP_NET_ADMIN` for
the host network namespace.

This will enable:
- Accelerated (and deflaked) `docker pull`, `docker push`, `docker build`, etc
- Proper support for `docker pull 127.0.0.1:.../...`
- Proper support for `dockern run --net=host`

See also:
- rootless-containers/rootlesskit PR 379
- containerd/nerdctl PR 2723

NOTE: libnetwork contains code generated by Claude Code

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-04-10 02:02:51 +09:00
Albin Kerouanton
310aa9241a libnet/pm: log when stopping userland proxy
Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
2025-11-28 19:40:37 +01:00
Albin Kerouanton
9efc1cc264 libnet/portmapper: rename, move PortMapper to portallocator
The only viable way to allocate a port is to bind and listen to it. So,
the windows PortMapper was really a PortAllocator in disguise.

Rename it to OSAllocator and move it to the portallocator package.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 11:32:21 +02:00
Albin Kerouanton
af677b61a5 libnet/portmapper: clean up windows port mapper
The windows port mapper is needlessly complex while its job is pretty
straightforward: reserve a port through the port allocator, and start a
dummy proxy to allocate it from the OS.

The biggest source of complexity is the use of the `net.Addr` interface
to pass the host IP, port and proto. `MapRange` now has a proto arg, and
returns the allocated port.

`MapRange` is also instantiating a `mapping` struct whose fields are
all unused, except for its `stopUserlandProxy`. Instead, store
`stopProxy` callbacks directly into the `PortMapper`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 10:05:29 +02:00
Albin Kerouanton
90f31c6c27 libnet/portmapper: remove dead field bridgeName
This field is not referenced by anything. Drop it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 09:55:09 +02:00
Albin Kerouanton
f6e5b3afc5 libnet/portmapper: drop unused NewWithPortAllocator
This function is only called by New, and it takes the singleton
PortAllocator exposed by the portallocator package.

Remove this function and instantiate the PortMapper directly from New
constructor.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 09:55:05 +02:00
Albin Kerouanton
9e7de1b679 libnet/portmapper: remove unused field proxyPath
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 09:55:02 +02:00
Albin Kerouanton
f6c59f9779 libnet/portmapper: merge mapper.go & mapper_windows.go
The portmapper struct provided by libnet/portmapper is only available
on Windows. Merge both files to reflect that.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 09:52:33 +02:00
Albin Kerouanton
b48442db4c libnet/portmapper: remove dead DeleteForwardingTableEntry
Prior to commit 4f09af626, DeleteForwardingTableEntry had a Linux
implementation. That's not the case anymore, and it's a no-op on
Windows. Remove it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 09:52:14 +02:00
Albin Kerouanton
32710d3e5e libnet/portmapper: remove dead AppendForwardingTableEntry
Prior to commit 4f09af626, AppendForwardingTableEntry had a Linux
implementation. That's not the case anymore, and it's a no-op on
Windows. Remove it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-08 09:11:33 +02:00
Derek McGowan
f74e5d48b3 Create github.com/moby/moby/v2 module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-31 10:13:29 -07:00
Derek McGowan
7a720df61f Move libnetwork to daemon/libnetwork
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-14 09:25:23 -07:00