Tianon Gravi 8955d8da89 Merge pull request #42981 from frobnicaty/patch-1 3 năm trước cách đây
..
bitseq c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
cluster 0f6cb61f2d Switch from x/net/context -> context 7 năm trước cách đây
cmd c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
config c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
datastore 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
diagnostic ea5c94cdb9 pkg/signal: move signal.DumpStacks() to a separate package 4 năm trước cách đây
discoverapi a1ed5b7be2 fix nits in comments and log 8 năm trước cách đây
docs 14fbe41991 Update design.md 5 năm trước cách đây
driverapi 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
drivers c721bad8cc Fix flaky TestPortMappingV6Config 3 năm trước cách đây
drvregistry 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
etchosts c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
hostdiscovery 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
idm 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
internal 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
ipam c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
ipamapi c23eae3114 libnetwork/ipamapi: godoc fixes 4 năm trước cách đây
ipams c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
ipamutils 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
iptables 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
netlabel 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
netutils 2b70006e3b Merge pull request #42777 from thaJeztah/update_go_1.17 4 năm trước cách đây
networkdb d78b883576 Fix grammar for "does not exist" 3 năm trước cách đây
ns 9a4025d79f Revert "Adjust LockOSThread" 6 năm trước cách đây
options 427ad30c05 libnetwork: remove unused "testutils" imports 4 năm trước cách đây
osl c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
portallocator 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
portmapper c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
resolvconf c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
support 4b981436fe Fixup libnetwork lint errors 4 năm trước cách đây
test a384f83e7a libnetwork: remove CircleCI config and code 4 năm trước cách đây
testutils 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
types 073f8df0fe libnetwork/types: remove TransportPort.FromString() as it's unused 4 năm trước cách đây
.dockerignore 62ebaeac7a Added back dockerignore 7 năm trước cách đây
.gitignore 62ebaeac7a Added back dockerignore 7 năm trước cách đây
CHANGELOG.md a06f1b2c4e Spelling fixes 7 năm trước cách đây
README.md a384f83e7a libnetwork: remove CircleCI config and code 4 năm trước cách đây
agent.go 4b981436fe Fixup libnetwork lint errors 4 năm trước cách đây
agent.pb.go 7d7412f957 Gracefully remove LB endpoints from services 7 năm trước cách đây
agent.proto 7d7412f957 Gracefully remove LB endpoints from services 7 năm trước cách đây
controller.go 4b981436fe Fixup libnetwork lint errors 4 năm trước cách đây
default_gateway.go 4b981436fe Fixup libnetwork lint errors 4 năm trước cách đây
default_gateway_freebsd.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
default_gateway_linux.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
default_gateway_windows.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
drivers_freebsd.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
drivers_ipam.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
drivers_linux.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
drivers_windows.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
endpoint.go 350e303c7f endpoint: remove redundant doUpdateHostsFile() function 4 năm trước cách đây
endpoint_cnt.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
endpoint_info.go 116f200737 Fix gosec complaints in libnetwork 4 năm trước cách đây
endpoint_info_unix.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
endpoint_info_windows.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
endpoint_test.go c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
error.go fc4d9bd640 Merge pull request #1616 from chchliang/testnetwork 8 năm trước cách đây
errors_test.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
firewall_linux.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
firewall_linux_test.go b3c883bb2f Skip libnetwork integration tests on Windows 4 năm trước cách đây
firewall_others.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
libnetwork_internal_test.go b3c883bb2f Skip libnetwork integration tests on Windows 4 năm trước cách đây
libnetwork_linux_test.go c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
libnetwork_test.go eadf839530 fix TestInvalidRemoteDriver() to check underlying error 3 năm trước cách đây
libnetwork_unix_test.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
libnetwork_windows_test.go b3c883bb2f Skip libnetwork integration tests on Windows 4 năm trước cách đây
network.go 92ea7df3d1 libnetwork: fix some linting issues 4 năm trước cách đây
network_unix.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
network_windows.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
resolver.go 79d6e935ad libnetwork: some minor refactoring / cleanup 3 năm trước cách đây
resolver_test.go b3c883bb2f Skip libnetwork integration tests on Windows 4 năm trước cách đây
resolver_unix.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
resolver_windows.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
sandbox.go 4b981436fe Fixup libnetwork lint errors 4 năm trước cách đây
sandbox_dns_unix.go c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
sandbox_dns_windows.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
sandbox_externalkey.go ffbe62a8f7 sandbox_externalkey.go: split for cross compilation 9 năm trước cách đây
sandbox_externalkey_unix.go c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
sandbox_externalkey_windows.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
sandbox_store.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
sandbox_test.go b3c883bb2f Skip libnetwork integration tests on Windows 4 năm trước cách đây
service.go a0a473125b Fix libnetwork imports 4 năm trước cách đây
service_common.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
service_common_test.go b3c883bb2f Skip libnetwork integration tests on Windows 4 năm trước cách đây
service_linux.go c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây
service_unsupported.go 686be57d0a Update to Go 1.17.0, and gofmt with Go 1.17 4 năm trước cách đây
service_windows.go 31d3468146 windows: remove redundant init() 4 năm trước cách đây
store.go 3ad9549e70 Merge pull request #42545 from steffengy/master 4 năm trước cách đây
store_linux_test.go 4b981436fe Fixup libnetwork lint errors 4 năm trước cách đây
store_test.go c55a4ac779 refactor: move from io/ioutil to io and os package 4 năm trước cách đây

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("docker.io"))
	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.