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

..27-Aug-2018-

bitseq/H27-Aug-2018-880662

cluster/H27-Aug-2018-3826

config/H27-Aug-2018-308239

datastore/H27-Aug-2018-970682

diagnostic/H27-Aug-2018-361266

discoverapi/H27-Aug-2018-6135

driverapi/H27-Aug-2018-375204

drivers/H27-Aug-2018-14,77011,573

drvregistry/H27-Aug-2018-229163

etchosts/H27-Aug-2018-209156

hostdiscovery/H27-Aug-2018-145114

idm/H27-Aug-2018-7754

internal/H27-Aug-2018-166121

ipam/H27-Aug-2018-1,227938

ipamapi/H27-Aug-2018-10852

ipams/H27-Aug-2018-590433

ipamutils/H27-Aug-2018-13699

iptables/H27-Aug-2018-804610

ipvs/H27-Aug-2018-890615

netlabel/H27-Aug-2018-13065

netutils/H27-Aug-2018-372262

networkdb/H27-Aug-2018-5,9564,903

ns/H27-Aug-2018-141115

options/H27-Aug-2018-8956

osl/H27-Aug-2018-1,9981,432

portallocator/H27-Aug-2018-321252

portmapper/H27-Aug-2018-485398

resolvconf/H27-Aug-2018-281202

types/H27-Aug-2018-654449

LICENSEH A D27-Aug-201811.1 KiB203169

README.mdH A D27-Aug-20183.7 KiB10177

agent.goH A D27-Aug-201826.2 KiB976784

agent.pb.goH A D27-Aug-201827.9 KiB1,0961,012

agent.protoH A D27-Aug-20182.5 KiB7758

controller.goH A D27-Aug-201834.6 KiB1,3391,002

default_gateway.goH A D27-Aug-20185.2 KiB204146

default_gateway_freebsd.goH A D27-Aug-2018326 149

default_gateway_linux.goH A D27-Aug-2018694 3325

default_gateway_windows.goH A D27-Aug-2018539 2317

drivers_experimental_linux.goH A D27-Aug-2018170 107

drivers_freebsd.goH A D27-Aug-2018258 1411

drivers_ipam.goH A D27-Aug-2018713 2622

drivers_linux.goH A D27-Aug-2018629 2723

drivers_windows.goH A D27-Aug-2018602 2219

endpoint.goH A D27-Aug-201830.8 KiB1,219953

endpoint_cnt.goH A D27-Aug-20183.4 KiB183147

endpoint_info.goH A D27-Aug-201811.3 KiB460362

endpoint_info_unix.goH A D27-Aug-2018655 3122

endpoint_info_windows.goH A D27-Aug-2018906 4634

error.goH A D27-Aug-20185.5 KiB19499

firewall_linux.goH A D27-Aug-20181,008 4131

firewall_others.goH A D27-Aug-201887 73

network.goH A D27-Aug-201855.9 KiB2,2091,716

network_unix.goH A D27-Aug-2018267 157

network_windows.goH A D27-Aug-20181.9 KiB7662

resolver.goH A D27-Aug-201814 KiB556433

resolver_unix.goH A D27-Aug-20183 KiB10282

resolver_windows.goH A D27-Aug-201895 84

sandbox.goH A D27-Aug-201830.7 KiB1,248926

sandbox_dns_unix.goH A D27-Aug-201812.7 KiB435330

sandbox_dns_windows.goH A D27-Aug-2018566 3621

sandbox_externalkey.goH A D27-Aug-2018209 139

sandbox_externalkey_unix.goH A D27-Aug-20183.9 KiB177141

sandbox_externalkey_windows.goH A D27-Aug-20181.3 KiB4627

sandbox_store.goH A D27-Aug-20186.9 KiB304243

service.goH A D27-Aug-20182.3 KiB9957

service_common.goH A D27-Aug-201812.2 KiB402284

service_linux.goH A D27-Aug-201822.6 KiB768613

service_unsupported.goH A D27-Aug-2018595 2617

service_windows.goH A D27-Aug-20184.1 KiB174136

store.goH A D27-Aug-201811.4 KiB497388

vendor.confH A D27-Aug-20182.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