1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/libnetwork
Alessandro Boch 3da75632f7 Reorganize MAC generation functions
- We have more than one function doing the same thing

Signed-off-by: Alessandro Boch <aboch@docker.com>
2015-07-30 11:06:16 -07:00
..
api
bitseq BitSequence should unmarshal data during get 2015-07-06 11:25:42 -07:00
client Reduced the two spaces for network help, required to pass tests at docker build 2015-07-23 11:46:57 +09:00
cmd
config
datastore
docs Merge pull request #357 from runseb/vagrant-docs 2015-07-07 09:19:15 +08:00
driverapi
drivers Reorganize MAC generation functions 2015-07-30 11:06:16 -07:00
etchosts
Godeps Remove dependency on libcontainer 2015-07-16 13:26:26 -07:00
hostdiscovery
idm
ipallocator Misc fixes to ipallocator & bridge driver about FixedCIDR 2015-07-27 18:12:33 -07:00
ipam
iptables
netlabel
netutils Reorganize MAC generation functions 2015-07-30 11:06:16 -07:00
options
portallocator fix file descriptor leak of ".../ip_local_port_range" 2015-07-07 16:56:24 -07:00
portmapper Fix ICC on Firewalld enabled fedora systems, add in missing firewalld functionality to re-apply configuration when reloaded 2015-07-24 13:20:48 -04:00
resolvconf
sandbox deadlock fix in RemoveStaticRoute 2015-07-24 01:32:35 -07:00
test/integration
types Misc fixes to ip allocation in bridge driver 2015-07-24 16:59:27 -07:00
.gitignore
circle.yml
controller.go
drivers_freebsd.go
drivers_linux.go
drivers_windows.go
endpoint.go Honor driver side resolv.conf file 2015-07-02 10:39:06 -07:00
endpoint_info.go
error.go
errors_test.go
libnetwork_internal_test.go
libnetwork_test.go Fix data race in controller sandboxes 2015-07-29 23:57:50 -07:00
LICENSE
MAINTAINERS
Makefile Use github golang tools mirror 2015-07-01 12:57:39 +08:00
network.go
README.md FIX incorrect usage about libnetwork.New() in README.md 2015-07-20 21:59:05 +08:00
ROADMAP.md
sandboxdata.go Fix data race in controller sandboxes 2015-07-29 23:57:50 -07:00
sandboxdata_test.go
store.go

libnetwork - networking for containers

Circle CI Coverage Status GoDoc

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.

NOTE: libnetwork project is under heavy development and is not ready for general use.

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.

        // Create a new controller instance
        controller, err := libnetwork.New()
        if err != nil {
                return
        }

        // Select and configure the network driver
        networkType := "bridge"

        driverOptions := options.Generic{}
        genericOption := make(map[string]interface{})
        genericOption[netlabel.GenericData] = driverOptions
        err := controller.ConfigureNetworkDriver(networkType, genericOption)
        if err != nil {
                return
        }

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

        // 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 {
                return
        }

        // A container can join the endpoint by providing the container ID to the join
        // api.
        // Join accepts Variadic arguments which will be made use of by libnetwork and Drivers
        err = ep.Join("container1",
                libnetwork.JoinOptionHostname("test"),
                libnetwork.JoinOptionDomainname("docker.io"))
        if err != nil {
                return
        }

		// libnetwork client can check the endpoint's operational data via the Info() API
		epInfo, err := ep.DriverInfo()
		mapData, ok := epInfo[netlabel.PortMap]
		if ok {
			portMapping, ok := mapData.([]netutils.PortBinding)
			if ok {
				fmt.Printf("Current port mapping for endpoint %s: %v", ep.Name(), portMapping)
			}
		}

Current Status

Please watch this space for updates on the progress.

Currently libnetwork is nothing more than an attempt to modularize the Docker platform's networking subsystem by moving it into libnetwork as a library.

Future

Please refer to roadmap for more information.

Contributing

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

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