• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..10-Apr-2019-

bitseq/H10-Apr-2019-880662

cluster/H10-Apr-2019-3826

config/H10-Apr-2019-308239

datastore/H10-Apr-2019-970682

diagnostic/H10-Apr-2019-361266

discoverapi/H10-Apr-2019-6135

driverapi/H10-Apr-2019-375204

drivers/H10-Apr-2019-14,78911,591

drvregistry/H10-Apr-2019-229163

etchosts/H10-Apr-2019-209156

hostdiscovery/H10-Apr-2019-145114

idm/H10-Apr-2019-7754

internal/H10-Apr-2019-166121

ipam/H10-Apr-2019-1,227938

ipamapi/H10-Apr-2019-10852

ipams/H10-Apr-2019-590433

ipamutils/H10-Apr-2019-13699

iptables/H10-Apr-2019-804610

ipvs/H10-Apr-2019-910623

netlabel/H10-Apr-2019-13065

netutils/H10-Apr-2019-372262

networkdb/H10-Apr-2019-5,9614,908

ns/H10-Apr-2019-141115

options/H10-Apr-2019-8956

osl/H10-Apr-2019-2,0321,461

portallocator/H10-Apr-2019-321252

portmapper/H10-Apr-2019-485398

resolvconf/H10-Apr-2019-281202

types/H10-Apr-2019-654449

LICENSEH A D10-Apr-201911.1 KiB203169

README.mdH A D10-Apr-20193.7 KiB10177

agent.goH A D10-Apr-201926.2 KiB976784

agent.pb.goH A D10-Apr-201927.9 KiB1,0961,012

agent.protoH A D10-Apr-20192.5 KiB7758

controller.goH A D10-Apr-201935.5 KiB1,3581,010

default_gateway.goH A D10-Apr-20195.1 KiB202144

default_gateway_freebsd.goH A D10-Apr-2019326 149

default_gateway_linux.goH A D10-Apr-2019694 3325

default_gateway_windows.goH A D10-Apr-2019539 2317

drivers_experimental_linux.goH A D10-Apr-2019170 107

drivers_freebsd.goH A D10-Apr-2019258 1411

drivers_ipam.goH A D10-Apr-2019713 2622

drivers_linux.goH A D10-Apr-2019629 2723

drivers_windows.goH A D10-Apr-2019602 2219

endpoint.goH A D10-Apr-201930.8 KiB1,219953

endpoint_cnt.goH A D10-Apr-20193.4 KiB183147

endpoint_info.goH A D10-Apr-201911.3 KiB460362

endpoint_info_unix.goH A D10-Apr-2019655 3122

endpoint_info_windows.goH A D10-Apr-2019906 4634

error.goH A D10-Apr-20195.5 KiB19499

firewall_linux.goH A D10-Apr-20191,008 4131

firewall_others.goH A D10-Apr-201987 73

network.goH A D10-Apr-201956.2 KiB2,2201,726

network_unix.goH A D10-Apr-2019267 157

network_windows.goH A D10-Apr-20191.9 KiB7662

resolver.goH A D10-Apr-201914 KiB556433

resolver_unix.goH A D10-Apr-20193 KiB10282

resolver_windows.goH A D10-Apr-201995 84

sandbox.goH A D10-Apr-201931.6 KiB1,270946

sandbox_dns_unix.goH A D10-Apr-201912.7 KiB435330

sandbox_dns_windows.goH A D10-Apr-2019566 3621

sandbox_externalkey.goH A D10-Apr-2019209 139

sandbox_externalkey_unix.goH A D10-Apr-20193.8 KiB177141

sandbox_externalkey_windows.goH A D10-Apr-20191.3 KiB4627

sandbox_store.goH A D10-Apr-20196.9 KiB304243

service.goH A D10-Apr-20192.3 KiB9957

service_common.goH A D10-Apr-201912.2 KiB402284

service_linux.goH A D10-Apr-201922.9 KiB775620

service_unsupported.goH A D10-Apr-2019595 2617

service_windows.goH A D10-Apr-20194.1 KiB174136

store.goH A D10-Apr-201911.4 KiB497388

vendor.confH A D10-Apr-20192.6 KiB5248

README.md

1# libnetwork - networking for containers
2
3[![Circle CI](https://circleci.com/gh/docker/libnetwork/tree/master.svg?style=svg)](https://circleci.com/gh/docker/libnetwork/tree/master) [![Coverage Status](https://coveralls.io/repos/docker/libnetwork/badge.svg)](https://coveralls.io/r/docker/libnetwork) [![GoDoc](https://godoc.org/github.com/docker/libnetwork?status.svg)](https://godoc.org/github.com/docker/libnetwork) [![Go Report Card](https://goreportcard.com/badge/github.com/docker/libnetwork)](https://goreportcard.com/report/github.com/docker/libnetwork)
4
5Libnetwork provides a native Go implementation for connecting containers
6
7The goal of libnetwork is to deliver a robust Container Network Model that provides a consistent programming interface and the required network abstractions for applications.
8
9#### Design
10Please refer to the [design](docs/design.md) for more information.
11
12#### Using libnetwork
13
14There 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.
15
16
17```go
18import (
19	"fmt"
20	"log"
21
22	"github.com/docker/docker/pkg/reexec"
23	"github.com/docker/libnetwork"
24	"github.com/docker/libnetwork/config"
25	"github.com/docker/libnetwork/netlabel"
26	"github.com/docker/libnetwork/options"
27)
28
29func main() {
30	if reexec.Init() {
31		return
32	}
33
34	// Select and configure the network driver
35	networkType := "bridge"
36
37	// Create a new controller instance
38	driverOptions := options.Generic{}
39	genericOption := make(map[string]interface{})
40	genericOption[netlabel.GenericData] = driverOptions
41	controller, err := libnetwork.New(config.OptionDriverConfig(networkType, genericOption))
42	if err != nil {
43		log.Fatalf("libnetwork.New: %s", err)
44	}
45
46	// Create a network for containers to join.
47	// NewNetwork accepts Variadic optional arguments that libnetwork and Drivers can use.
48	network, err := controller.NewNetwork(networkType, "network1", "")
49	if err != nil {
50		log.Fatalf("controller.NewNetwork: %s", err)
51	}
52
53	// For each new container: allocate IP and interfaces. The returned network
54	// settings will be used for container infos (inspect and such), as well as
55	// iptables rules for port publishing. This info is contained or accessible
56	// from the returned endpoint.
57	ep, err := network.CreateEndpoint("Endpoint1")
58	if err != nil {
59		log.Fatalf("network.CreateEndpoint: %s", err)
60	}
61
62	// Create the sandbox for the container.
63	// NewSandbox accepts Variadic optional arguments which libnetwork can use.
64	sbx, err := controller.NewSandbox("container1",
65		libnetwork.OptionHostname("test"),
66		libnetwork.OptionDomainname("docker.io"))
67	if err != nil {
68		log.Fatalf("controller.NewSandbox: %s", err)
69	}
70
71	// A sandbox can join the endpoint via the join api.
72	err = ep.Join(sbx)
73	if err != nil {
74		log.Fatalf("ep.Join: %s", err)
75	}
76
77	// libnetwork client can check the endpoint's operational data via the Info() API
78	epInfo, err := ep.DriverInfo()
79	if err != nil {
80		log.Fatalf("ep.DriverInfo: %s", err)
81	}
82
83	macAddress, ok := epInfo[netlabel.MacAddress]
84	if !ok {
85		log.Fatalf("failed to get mac address from endpoint info")
86	}
87
88	fmt.Printf("Joined endpoint %s (%s) to sandbox %s (%s)\n", ep.Name(), macAddress, sbx.ContainerID(), sbx.Key())
89}
90```
91
92## Future
93Please refer to [roadmap](ROADMAP.md) for more information.
94
95## Contributing
96
97Want to hack on libnetwork? [Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) apply.
98
99## Copyright and license
100Code and documentation copyright 2015 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons.
101