Cory Snider a264f2dc55 libnetwork/ipam: skip Destroy()ing bitseq.Handle values hace 2 años
..
bitmap 6f08fe20e9 libnetwork/bit{seq,map}: delete CheckConsistency() hace 2 años
bitseq 6f08fe20e9 libnetwork/bit{seq,map}: delete CheckConsistency() hace 2 años
cluster 0f6cb61f2d Switch from x/net/context -> context hace 7 años
cmd 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
config 142b522946 libnetwork/config: remove vestiges of global scope hace 2 años
datastore 142b522946 libnetwork/config: remove vestiges of global scope hace 2 años
diagnostic 55fd77f724 set ReadHeaderTimeout to address G112: Potential Slowloris Attack (gosec) hace 2 años
discoverapi a08a254df3 libnetwork: drop DatastoreConfig discovery type hace 2 años
docs 147173b099 libnetwork: remove consul-related code and tests hace 3 años
driverapi 5595311209 libnetwork/drvregistry: split up the registries hace 2 años
drivers a08a254df3 libnetwork: drop DatastoreConfig discovery type hace 2 años
drvregistry 5595311209 libnetwork/drvregistry: split up the registries hace 2 años
etchosts 46f7c92c9a libnetwork: use strings.Cut() and minor refactor hace 2 años
idm 427ad30c05 libnetwork: remove unused "testutils" imports hace 4 años
internal 427ad30c05 libnetwork: remove unused "testutils" imports hace 4 años
ipam a264f2dc55 libnetwork/ipam: skip Destroy()ing bitseq.Handle values hace 2 años
ipamapi a08a254df3 libnetwork: drop DatastoreConfig discovery type hace 2 años
ipams a08a254df3 libnetwork: drop DatastoreConfig discovery type hace 2 años
ipamutils e8011d7872 libnw/ipamutils: make local defaults immutable hace 2 años
iptables 6ab12ec8f4 rootless: move ./rootless to ./pkg/rootless hace 2 años
netlabel a959487597 libnetwork/netlabel: remove Key(), Value(), and KeyValue() utils hace 2 años
netutils e8011d7872 libnw/ipamutils: make local defaults immutable hace 2 años
networkdb eaa74497b8 libnetwork: use go-immutable-radix instead of radix hace 2 años
ns 7fc29c1435 libnetwork/osl: clean up Linux InvokeFunc() hace 2 años
options 2f1c382a6d golangci-lint: update to v1.49.0 hace 2 años
osl 7037c48e58 libnetwork: set IPv6 without reexec hace 2 años
portallocator c2a087a9f7 libnet/d/bridge: use fresh PortAllocator in tests hace 2 años
portmapper 1f22b15030 Lock OS threads when exec'ing with Pdeathsig hace 2 años
resolvconf 49de15cdcc libnetwork/resolvconf: removed unused GetIfChanged() and GetLastModified() hace 2 años
support 4b981436fe Fixup libnetwork lint errors hace 4 años
testutils 9a0953a0a0 libnet/testutils: spawn goroutines in test OS ctxs hace 2 años
types 145817a9cf libnetwork: use strconv instead of fmt.Sprintf() hace 2 años
.dockerignore 62ebaeac7a Added back dockerignore hace 7 años
.gitignore 62ebaeac7a Added back dockerignore hace 7 años
CHANGELOG.md a06f1b2c4e Spelling fixes hace 7 años
README.md 65aa43bf66 libnetwork: use example.com for tests and examples hace 2 años
agent.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
agent.pb.go 7d7412f957 Gracefully remove LB endpoints from services hace 7 años
agent.proto 7d7412f957 Gracefully remove LB endpoints from services hace 7 años
controller.go 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
default_gateway.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
default_gateway_freebsd.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
default_gateway_linux.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
default_gateway_windows.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
drivers_freebsd.go 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
drivers_ipam.go d478e13639 libnet: un-plumb datastores from IPAM inits hace 2 años
drivers_linux.go 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
drivers_windows.go 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
endpoint.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años
endpoint_cnt.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años
endpoint_info.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
endpoint_info_unix.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
endpoint_info_windows.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
endpoint_test.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
error.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años
errors_test.go cd381aea56 libnetwork: fix empty-lines (revive) hace 2 años
firewall_linux.go ffd75c2e0c libnetwork: Support IPv6 in arrangeUserFilterRule() (redux) hace 2 años
firewall_linux_test.go ffd75c2e0c libnetwork: Support IPv6 in arrangeUserFilterRule() (redux) hace 2 años
firewall_others.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
libnetwork_internal_test.go 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
libnetwork_linux_test.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
libnetwork_test.go 142b522946 libnetwork/config: remove vestiges of global scope hace 2 años
libnetwork_unix_test.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 hace 4 años
libnetwork_windows_test.go b3c883bb2f Skip libnetwork integration tests on Windows hace 4 años
network.go 28edc8e2d6 libnet: convert to new-style driver registration hace 2 años
network_unix.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 hace 4 años
network_windows.go d6cc02d301 libnetwork: drop (resolver).resolverKey field hace 2 años
resolver.go d6cc02d301 libnetwork: drop (resolver).resolverKey field hace 2 años
resolver_test.go 0e91d2e0e9 libnetwork: return concrete-typed *Sandbox hace 2 años
resolver_unix.go 50a4951ddc libnetwork: setup DNS resolver without reexec hace 2 años
resolver_windows.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 hace 4 años
sandbox.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
sandbox_dns_unix.go 0e91d2e0e9 libnetwork: return concrete-typed *Sandbox hace 2 años
sandbox_dns_windows.go 0e91d2e0e9 libnetwork: return concrete-typed *Sandbox hace 2 años
sandbox_externalkey.go ffbe62a8f7 sandbox_externalkey.go: split for cross compilation hace 9 años
sandbox_externalkey_unix.go 0e91d2e0e9 libnetwork: return concrete-typed *Sandbox hace 2 años
sandbox_externalkey_windows.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
sandbox_store.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años
sandbox_test.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
service.go a0a473125b Fix libnetwork imports hace 4 años
service_common.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
service_common_test.go 0e91d2e0e9 libnetwork: return concrete-typed *Sandbox hace 2 años
service_linux.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
service_unsupported.go f96b9bf761 libnetwork: return concrete-typed *Controller hace 2 años
service_windows.go c71555f030 libnetwork: return concrete-typed *Endpoint hace 2 años
store.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años
store_linux_test.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años
store_test.go befff0e13f libnetwork: remove more datastore scope plumbing hace 2 años

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/pkg/reexec"
	"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() {
	if reexec.Init() {
		return
	}

	// 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.Fatalf("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.