Help us shape the future of Go! Take the 2026 Go Developer Survey

dockernet

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package dockernet carves Docker bridge networks out of an address range of Pando's own rather than Docker's default pool, which holds about thirty networks (issue #55). The Docker runtime adapter makes app networks with it, and the BuildKit builder each app's build network.

It imports nothing from core.

Index

Constants

View Source
const DefaultPool = "10.213.0.0/16"

DefaultPool is the range Pando's networks take their addresses from when none is set: app networks (/28s) and build networks (/29s) alike, kept apart by the overlap check in Create. An unusual corner of private space; an install whose own LAN uses it sets another.

Variables

This section is empty.

Functions

func BlockTaken

func BlockTaken(err error) bool

BlockTaken reports a refusal that means only "that block is in use", which is a reason to try the next one rather than to fail.

In the engine's words, because nothing else says which refusal it was. Docker answers "Pool overlaps with other one on this address space". Podman checks the host's routes as well as its own networks and answers "subnet … is already used on the host or by another config" — and a block another engine on the same machine holds is exactly what it finds there. Reading only Docker's wording failed every deploy on such a Podman at the first taken block.

func Create

func Create(ctx context.Context, cli API, name string, pool netip.Prefix, bits int, opts client.NetworkCreateOptions) (client.NetworkCreateResult, error)

Create creates a bridge network with an address block of bits from pool, falling back to Docker's own allocation when the network list cannot be read or every block tried was refused.

The caller serializes calls that share a pool: two creates choosing at once would both see the same free block. Docker still has the last word — a block taken by something outside the process is refused as overlapping — so a refusal moves on to the next block rather than failing.

func FreeBlocks

func FreeBlocks(pool netip.Prefix, bits int, used []netip.Prefix) func(func(netip.Prefix) bool)

FreeBlocks yields the pool's blocks of the given size that overlap nothing in use, in order. Blocks of different sizes share the pool: each is aligned to its own size, so the overlap check is all that keeps them apart.

func UsedSubnets

func UsedSubnets(ctx context.Context, cli API) ([]netip.Prefix, error)

UsedSubnets lists every IPv4 subnet any Docker network on this host holds.

Types

type API

type API interface {
	NetworkList(ctx context.Context, opts client.NetworkListOptions) (client.NetworkListResult, error)
	NetworkCreate(ctx context.Context, name string, opts client.NetworkCreateOptions) (client.NetworkCreateResult, error)
}

API is the part of the Docker client a network is made with.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL