Linux: `docker network create` without an explicit subnet always fails with "no free subnet left" (breaks kind)

Open
#228 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, linux, rust

Research direction

Start by tracing the Linux engine's Docker network creation and automatic subnet allocation path; the issue does not name source files or tests. Reproduce with docker network create probe4 and with the IPv6-only pinned subnet command, then compare against explicit IPv4 subnet creation. Done means automatic allocation selects a free subnet and the reported kind network command succeeds.

Written by the indexing model from the issue text.

Description

Kiri version and system

0.2.0 (kiri-desktop-bin from the AUR) on CachyOS (Arch Linux), kernel 7.3.4-1-cachyos, systemd 262. Native Linux engine, no VM.

What you did

Create a network without specifying a subnet (the normal case):

$ docker --context kiri network create probe4

Variants that fail the same way: docker network create --ipv6 --subnet fc00:f853:ccd:e793::/64 probe6 (IPv6 pinned, IPv4 left to the pool — the exact command kind runs), and a plain docker network create test.

What happened
Error response from daemon: no free subnet left

This is with plenty of the default pool free. At the moment of the commands above, the host had these 172.16/12 addresses in use: 172.17.0.1/16 (docker0), 172.18.0.1/16 (an old bridge), 172.19.0.1/16 (kiri0) — everything from 172.20 upward was free.

Creating a network with an explicit --subnet works fine:

$ docker --context kiri network create probeA --subnet 172.22.0.0/16
4e20e6092921e57b1545a53f41abd8813e5e4ab4b0b54a66736bae95e7bb0709

So only the automatic pool allocation is broken, not network creation itself.

What you expected instead

Docker Engine allocates the next free subnet from the default address pool (172.17.0.0/12 in /16s, then 192.168.x): docker network create probe4 succeeds and picks e.g. 172.20.0.0/16.

Anything else

Happens 100% of the time on this machine.

This breaks kind out of the box: kind v0.27 creates its network as docker network create -d=bridge -o com.docker.network.bridge.enable_ip_masquerade=true --ipv6 --subnet fc00:f853:ccd:e793::/64 kind, i.e. with the IPv4 subnet left to the pool, so every kind create cluster fails with "no free subnet left".

Workaround I'm using: pre-create the network with explicit subnets before kind runs — kind finds a network named kind and reuses it:

$ docker --context kiri network create -d=bridge -o com.docker.network.bridge.enable_ip_masquerade=true --ipv6 --subnet fc00:f853:ccd:e793::/64 --subnet 172.20.0.0/16 kind

Related: #125 (Docker network compatibility).

Dominant language
Rust
Stars
7.5k
Forks
329
Avg merge
7h 48m
Merged PRs (30d)
105

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libracoder/kiri

All issues in libracoder/kiri

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.