Rob Murray 964ab7158c Explicitly set MTU on bridge devices. há 1 ano atrás
..
bitmap 564a13285f libnetwork/bitmap: improve documentation há 2 anos atrás
cluster 0f6cb61f2d Switch from x/net/context -> context há 7 anos atrás
cmd cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
config cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
datastore 4af420f978 libnetwork/internal/kvstore: prune unused method há 1 ano atrás
diagnostic cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
discoverapi a08a254df3 libnetwork: drop DatastoreConfig discovery type há 2 anos atrás
docs 9e817251a8 libnetwork/docs: fix broken link há 2 anos atrás
driverapi 42d34e40f9 libnet: Replace BadRequest with InvalidParameter há 2 anos atrás
drivers 964ab7158c Explicitly set MTU on bridge devices. há 1 ano atrás
drvregistry a0a8d9d057 libnetwork: notify another driver registerer há 1 ano atrás
etchosts 1cd937a867 libnetwork/etchosts: format code with gofumpt há 2 anos atrás
internal 4af420f978 libnetwork/internal/kvstore: prune unused method há 1 ano atrás
ipam 7257c77e19 libnetwork/ipam: refactor prefix-overlap checks há 1 ano atrás
ipamapi c22ec82477 libnet: Fix error capitalization há 2 anos atrás
ipams cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
ipamutils bba21735bf libnetwork/ipamutils: format code with gofumpt há 2 anos atrás
ipbits 3c59ef247f libnet/ipam: use netip types internally há 2 anos atrás
iptables cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
netlabel 808120e5b8 New `host_ipv6` bridge option to SNAT IPv6 connections há 1 ano atrás
netutils 492c09276d tests: Move libnetwork/testutils to internal/testutils/netnsutils há 2 anos atrás
networkdb cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
ns cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
options 948f55d0b7 libnetwork/options: remove unused NewGeneric, and use map[string]any há 2 anos atrás
osl cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
portallocator cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
portmapper cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
resolvconf cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
scope 6ec03d6745 libnetwork: move datastore Scope consts to libnetwork/scope há 2 anos atrás
support 4b981436fe Fixup libnetwork lint errors há 4 anos atrás
types bd0111c1f4 libnet: Replace NoServiceError with UnavailableError há 2 anos atrás
.dockerignore 62ebaeac7a Added back dockerignore há 7 anos atrás
.gitignore 62ebaeac7a Added back dockerignore há 7 anos atrás
README.md 17882ed614 libnetwork: update example in README.md há 2 anos atrás
agent.go adea457841 Merge pull request #46553 from thaJeztah/no_panic há 1 ano atrás
agent.pb.go fd72b134d5 update generated files há 2 anos atrás
agent.proto 1eaea43581 fix protos and "go generate" commands há 2 anos atrás
controller.go 677d41aa3b Plumb context through info endpoint há 1 ano atrás
controller_linux.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
controller_others.go 95abde479a libnetwork: implement Controller.setupOSLSandbox há 1 ano atrás
default_gateway.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
default_gateway_freebsd.go 64c6f72988 libnetwork: remove Network interface há 2 anos atrás
default_gateway_linux.go 64c6f72988 libnetwork: remove Network interface há 2 anos atrás
default_gateway_windows.go 64c6f72988 libnetwork: remove Network interface há 2 anos atrás
drivers_freebsd.go 77c2613d3a libnetwork: fix some missing imports on macOS and FreeBSD há 1 ano atrás
drivers_ipam.go d478e13639 libnet: un-plumb datastores from IPAM inits há 2 anos atrás
drivers_linux.go d519bde5da libnet/drivers: stop passing config to drivers... há 2 anos atrás
drivers_unsupported.go 77c2613d3a libnetwork: fix some missing imports on macOS and FreeBSD há 1 ano atrás
drivers_windows.go d519bde5da libnet/drivers: stop passing config to drivers... há 2 anos atrás
endpoint.go 524eef5d75 Merge pull request #46681 from corhere/libn/datastore-misc-cleanups há 1 ano atrás
endpoint_cnt.go 4039b9c9c4 libnetwork/datastore: drop (KVObject).DataScope() há 1 ano atrás
endpoint_info.go 8c6a46f643 libnetwork: Endpoint.AddStaticRoute don't create StaticRoute if unused há 1 ano atrás
endpoint_info_unix.go ab35df454d remove pre-go1.17 build-tags há 2 anos atrás
endpoint_info_windows.go ab35df454d remove pre-go1.17 build-tags há 2 anos atrás
endpoint_unix_test.go c0562d4eed libnetwork: rename unix-only testfiles há 2 anos atrás
error.go 42d34e40f9 libnet: Replace BadRequest with InvalidParameter há 2 anos atrás
errors_test.go 42d34e40f9 libnet: Replace BadRequest with InvalidParameter há 2 anos atrás
firewall_linux.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
firewall_linux_test.go 492c09276d tests: Move libnetwork/testutils to internal/testutils/netnsutils há 2 anos atrás
firewall_others.go 9484520327 libnetwork: arrangeUserFilterRule: don't return early há 2 anos atrás
libnetwork_internal_test.go 4de8459265 libnet: add OTEL tracing to the embedded DNS há 1 ano atrás
libnetwork_linux_test.go 677d41aa3b Plumb context through info endpoint há 1 ano atrás
libnetwork_unix_test.go ab35df454d remove pre-go1.17 build-tags há 2 anos atrás
libnetwork_windows_test.go dd5ea7e996 libnetwork: format code with gofumpt há 2 anos atrás
network.go 524eef5d75 Merge pull request #46681 from corhere/libn/datastore-misc-cleanups há 1 ano atrás
network_unix.go 64c6f72988 libnetwork: remove Network interface há 2 anos atrás
network_windows.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
resolver.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
resolver_test.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
resolver_unix.go 1178319313 libn: fix resolver restore w/ chatty 'iptables -C' há 2 anos atrás
resolver_unix_test.go de4ba13400 libnetwork: move resolver tests that were skipped on Windows há 2 anos atrás
resolver_windows.go ab35df454d remove pre-go1.17 build-tags há 2 anos atrás
sandbox.go 0456c0db87 libnetwork: refactor isDistributedControl() há 1 ano atrás
sandbox_dns_unix.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
sandbox_dns_unix_test.go 1e4e9161c5 libnetwork: move TestDNSOptions to a non-windows file há 2 anos atrás
sandbox_dns_windows.go a365fb0e9d libnetwork: move more osl.Sandbox related code to Linux-only files há 1 ano atrás
sandbox_externalkey_unix.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
sandbox_externalkey_unsupported.go ab35df454d remove pre-go1.17 build-tags há 2 anos atrás
sandbox_linux.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
sandbox_options.go 06e540c271 libnetwork: move all SandboxOptions to a separate file há 2 anos atrás
sandbox_store.go f0b89e63b9 Fix missing import for "scope" package há 1 ano atrás
sandbox_unix_test.go 6dba98cf38 libnetwork: implement Controller.GetSandbox(containerID) há 1 ano atrás
sandbox_unsupported.go b92cf68add libnetwork/osl: remove Sandbox and Info interfaces há 1 ano atrás
service.go 9e3a6ccf69 libn/i/setmatrix: make generic and constructorless há 2 anos atrás
service_common.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
service_common_unix_test.go c0562d4eed libnetwork: rename unix-only testfiles há 2 anos atrás
service_linux.go f20abbc96c libnetwork: use conntrack and --ctstate for all rules há 1 ano atrás
service_unsupported.go ab35df454d remove pre-go1.17 build-tags há 2 anos atrás
service_windows.go cff4f20c44 migrate to github.com/containerd/log v0.1.0 há 1 ano atrás
store.go 677d41aa3b Plumb context through info endpoint há 1 ano atrás
store_linux_test.go 02dc5ea720 libnetwork/datastore: remove Store.KVStore() há 2 anos atrás
store_test.go a5ee0d6af8 libnetwork: don't access KVStore directly in tests há 2 anos atrás

README.md

libnetwork - networking for containers

Libnetwork provides a native Go implementation for connecting containers

The goal of libnetwork is to deliver a robust Container Network Model that provides a consistent programming interface and the required network abstractions for applications.

Design

Please refer to the design for more information.

Using libnetwork

There are many networking solutions available to suit a broad range of use-cases. libnetwork uses a driver / plugin model to support all of these solutions while abstracting the complexity of the driver implementations by exposing a simple and consistent Network Model to users.

package main

import (
	"fmt"
	"log"

	"github.com/docker/docker/libnetwork"
	"github.com/docker/docker/libnetwork/config"
	"github.com/docker/docker/libnetwork/netlabel"
	"github.com/docker/docker/libnetwork/options"
)

func main() {
	// Select and configure the network driver
	networkType := "bridge"

	// Create a new controller instance
	driverOptions := options.Generic{}
	genericOption := make(map[string]interface{})
	genericOption[netlabel.GenericData] = driverOptions
	controller, err := libnetwork.New(config.OptionDriverConfig(networkType, genericOption))
	if err != nil {
		log.Fatalf("libnetwork.New: %s", err)
	}

	// Create a network for containers to join.
	// NewNetwork accepts Variadic optional arguments that libnetwork and Drivers can use.
	network, err := controller.NewNetwork(networkType, "network1", "")
	if err != nil {
		log.Fatalf("controller.NewNetwork: %s", err)
	}

	// For each new container: allocate IP and interfaces. The returned network
	// settings will be used for container infos (inspect and such), as well as
	// iptables rules for port publishing. This info is contained or accessible
	// from the returned endpoint.
	ep, err := network.CreateEndpoint("Endpoint1")
	if err != nil {
		log.Fatalf("network.CreateEndpoint: %s", err)
	}

	// Create the sandbox for the container.
	// NewSandbox accepts Variadic optional arguments which libnetwork can use.
	sbx, err := controller.NewSandbox("container1",
		libnetwork.OptionHostname("test"),
		libnetwork.OptionDomainname("example.com"))
	if err != nil {
		log.Fatalf("controller.NewSandbox: %s", err)
	}

	// A sandbox can join the endpoint via the join api.
	err = ep.Join(sbx)
	if err != nil {
		log.Fatalf("ep.Join: %s", err)
	}

	// libnetwork client can check the endpoint's operational data via the Info() API
	epInfo, err := ep.DriverInfo()
	if err != nil {
		log.Fatalf("ep.DriverInfo: %s", err)
	}

	macAddress, ok := epInfo[netlabel.MacAddress]
	if !ok {
		log.Fatal("failed to get mac address from endpoint info")
	}

	fmt.Printf("Joined endpoint %s (%s) to sandbox %s (%s)\n", ep.Name(), macAddress, sbx.ContainerID(), sbx.Key())
}

Contributing

Want to hack on libnetwork? Docker's contributions guidelines apply.

Copyright and license

Code and documentation copyright 2015 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons.