From: Dmitry Smirnov Date: Tue, 11 Sep 2018 04:03:46 +0000 (+0100) Subject: Import docker.io_18.06.1+dfsg1.orig-libnetwork.tar.xz X-Git-Tag: archive/raspbian/18.09.1+dfsg1-7+rpi1~21^6 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=4869e52c9fa2a179c35623ad893fcfed6d987b4e;p=docker.io.git Import docker.io_18.06.1+dfsg1.orig-libnetwork.tar.xz [dgit import orig docker.io_18.06.1+dfsg1.orig-libnetwork.tar.xz] --- 4869e52c9fa2a179c35623ad893fcfed6d987b4e diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..545fcde3 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,79 @@ +version: 2 + +defaults: &defaults + working_directory: ~/go/src/github.com/docker/libnetwork + docker: + # the following image is irrelevant for the build, everything is built inside a container, check the Makefile + - image: 'circleci/golang:latest' + environment: + dockerbuildargs: . + dockerargs: --privileged -e CIRCLECI + +jobs: + builder: + <<: *defaults + steps: + - checkout + - setup_remote_docker: + version: 18.05.0-ce + reusable: true + exclusive: false + - run: make builder + + build: + <<: *defaults + steps: + - checkout + - setup_remote_docker: + version: 18.05.0-ce + reusable: true + exclusive: false + - run: make build + + lint: + <<: *defaults + steps: + - checkout + - setup_remote_docker: + version: 18.05.0-ce + reusable: true + exclusive: false + - run: make check + + cross: + <<: *defaults + steps: + - checkout + - setup_remote_docker: + version: 18.05.0-ce + reusable: true + exclusive: false + - run: make cross + + unit-tests: + <<: *defaults + steps: + - checkout + - setup_remote_docker: + version: 18.05.0-ce + reusable: true + exclusive: false + - run: make unit-tests + +workflows: + version: 2 + ci: + jobs: + - builder + - build: + requires: + - builder + - lint: + requires: + - builder + - cross: + requires: + - builder + - unit-tests: + requires: + - builder diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..31de392a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +.dockerignore +Dockerfile +bin +tags diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..9151c618 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,199 @@ +# Changelog + +## 0.8.0-dev.2 (2016-05-07) +- Fix an issue which may arise during sandbox cleanup (https://github.com/docker/libnetwork/pull/1157) +- Fix cleanup logic in case of ipv6 allocation failure +- Don't add /etc/hosts record if container's ip is empty (--net=none) +- Fix default gw logic for internal networks +- Error when updating IPv6 gateway (https://github.com/docker/libnetwork/issues/1142) +- Fixes https://github.com/docker/libnetwork/issues/1113 +- Fixes https://github.com/docker/libnetwork/issues/1069 +- Fxies https://github.com/docker/libnetwork/issues/1117 +- Increase the concurrent query rate-limit count +- Changes to build libnetwork in Solaris + +## 0.8.0-dev.1 (2016-04-16) +- Fixes docker/docker#16964 +- Added maximum egress bandwidth qos for Windows + +## 0.7.0-rc.6 (2016-04-10) +- Flush cached resolver socket on default gateway change + +## 0.7.0-rc.5 (2016-04-08) +- Persist ipam driver options +- Fixes https://github.com/docker/libnetwork/issues/1087 +- Use go vet from go tool +- Godep update to pick up latest docker/docker packages +- Validate remote driver response using docker plugins package method. + +## 0.7.0-rc.4 (2016-04-06) +- Fix the handling for default gateway Endpoint join/leave. + +## 0.7.0-rc.3 (2016-04-05) +- Revert fix for default gateway endoint join/leave. Needs to be reworked. +- Persist the network internal mode for bridge networks + +## 0.7.0-rc.2 (2016-04-05) +- Fixes https://github.com/docker/libnetwork/issues/1070 +- Move IPAM resource initialization out of init() +- Initialize overlay driver before network delete +- Fix the handling for default gateway Endpoint join/lean + +## 0.7.0-rc.1 (2016-03-30) +- Fixes https://github.com/docker/libnetwork/issues/985 +- Fixes https://github.com/docker/libnetwork/issues/945 +- Log time taken to set sandbox key +- Limit number of concurrent DNS queries + +## 0.7.0-dev.10 (2016-03-21) +- Add IPv6 service discovery (AAAA records) in embedded DNS server +- Honor enableIPv6 flag in network create for the IP allocation +- Avoid V6 queries in docker domain going to external nameservers + +## 0.7.0-dev.9 (2016-03-18) +- Support labels on networks + +## 0.7.0-dev.8 (2016-03-16) +- Windows driver to respect user set MAC address. +- Fix possible nil pointer reference in ServeDNS() with concurrent go routines. +- Fix netns path setting from hook (for containerd integration) +- Clear cached udp connections on resolver Stop() +- Avoid network/endpoint count inconsistences and remove stale networks after ungraceful shutdown +- Fix possible endpoint count inconsistency after ungraceful shutdown +- Reject a null v4 IPAM slice in exp vlan drivers +- Removed experimental drivers modprobe check + +## 0.7.0-dev.7 (2016-03-11) +- Bumped up the minimum kernel version for ipvlan to 4.2 +- Removed modprobe from macvlan/ipvlan drivers to resolve docker IT failures +- Close dbus connection if firewalld is not started + +## 0.7.0-dev.6 (2016-03-10) +- Experimental support for macvlan and ipvlan drivers + +## 0.7.0-dev.5 (2016-03-08) +- Fixes https://github.com/docker/docker/issues/20847 +- Fixes https://github.com/docker/docker/issues/20997 +- Fixes issues unveiled by docker integ test over 0.7.0-dev.4 + +## 0.7.0-dev.4 (2016-03-07) +- Changed ownership of exposed ports and port-mapping options from Endpoint to Sandbox +- Implement DNS RR in the Docker embedded DNS server +- Fixes https://github.com/docker/libnetwork/issues/984 (multi container overlay veth leak) +- Libnetwork to program container's interface MAC address +- Fixed bug in iptables.Exists() logic +- Fixes https://github.com/docker/docker/issues/20694 +- Source external DNS queries from container namespace +- Added inbuilt nil IPAM driver +- Windows drivers integration fixes +- Extract hostname from (hostname.domainname). Related to https://github.com/docker/docker/issues/14282 +- Fixed race in sandbox statistics read +- Fixes https://github.com/docker/libnetwork/issues/892 (docker start fails when ipv6.disable=1) +- Fixed error message on bridge network creation conflict + +## 0.7.0-dev.3 (2016-02-17) +- Fixes https://github.com/docker/docker/issues/20350 +- Fixes https://github.com/docker/docker/issues/20145 +- Initial Windows HNS integration +- Allow passing global datastore config to libnetwork after boot +- Set Recursion Available bit in DNS query responses +- Make sure iptables chains are recreated on firewalld reload + +## 0.7.0-dev.2 (2016-02-11) +- Fixes https://github.com/docker/docker/issues/20140 + +## 0.7.0-dev.1 (2016-02-10) +- Expose EnableIPV6 option +- discoverapi refactoring +- Fixed a few typos & docs update + +## 0.6.1-rc2 (2016-02-09) +- Fixes https://github.com/docker/docker/issues/20132 +- Fixes https://github.com/docker/docker/issues/20140 +- Fixes https://github.com/docker/docker/issues/20019 + +## 0.6.1-rc1 (2016-02-05) +- Fixes https://github.com/docker/docker/issues/20026 + +## 0.6.0-rc7 (2016-02-01) +- Allow inter-network connections via exposed ports + +## 0.6.0-rc6 (2016-01-30) +- Properly fixes https://github.com/docker/docker/issues/18814 + +## 0.6.0-rc5 (2016-01-26) +- Cleanup stale overlay sandboxes + +## 0.6.0-rc4 (2016-01-25) +- Add Endpoints() API to Sandbox interface +- Fixed a race-condition in default gateway network creation + +## 0.6.0-rc3 (2016-01-25) +- Fixes docker/docker#19576 +- Fixed embedded DNS to listen in TCP as well +- Fixed a race-condition in IPAM to choose non-overlapping subnet for concurrent requests + +## 0.6.0-rc2 (2016-01-21) +- Fixes docker/docker#19376 +- Fixes docker/docker#15819 +- Fixes libnetwork/#885, Not filter v6 DNS servers from resolv.conf +- Fixes docker/docker #19448, also handles the . in service and network names correctly. + +## 0.6.0-rc1 (2016-01-14) +- Fixes docker/docker#19404 +- Fixes the ungraceful daemon restart issue in systemd with remote network plugin + (https://github.com/docker/libnetwork/issues/813) + +## 0.5.6 (2016-01-14) +- Setup embedded DNS server correctly on container restart. Fixes docker/docker#19354 + +## 0.5.5 (2016-01-14) +- Allow network-scoped alias to be resolved for anonymous endpoint +- Self repair corrupted IP database that could happen in 1.9.0 & 1.9.1 +- Skip IPTables cleanup if --iptables=false is set. Fixes docker/docker#19063 + +## 0.5.4 (2016-01-12) +- Removed the isNodeAlive protection when user forces an endpoint delete + +## 0.5.3 (2016-01-12) +- Bridge driver supporting internal network option +- Backend implementation to support "force" option to network disconnect +- Fixing a regex in etchosts package to fix docker/docker#19080 + +## 0.5.2 (2016-01-08) +- Embedded DNS replacing /etc/hosts based Service Discovery +- Container local alias and Network-scoped alias support +- Backend support for internal network mode +- Support for IPAM driver options +- Fixes overlay veth cleanup issue : docker/docker#18814 +- fixes docker/docker#19139 +- disable IPv6 Duplicate Address Detection + +## 0.5.1 (2015-12-07) +- Allowing user to assign IP Address for containers +- Fixes docker/docker#18214 +- Fixes docker/docker#18380 + +## 0.5.0 (2015-10-30) + +- Docker multi-host networking exiting experimental channel +- Introduced IP Address Management and IPAM drivers +- DEPRECATE service discovery from default bridge network +- Introduced new network UX +- Support for multiple networks in bridge driver +- Local persistence with boltdb + +## 0.4.0 (2015-07-24) + +- Introduce experimental version of Overlay driver +- Introduce experimental version of network plugins +- Introduce experimental version of network & service UX +- Introduced experimental /etc/hosts based service discovery +- Integrated with libkv +- Improving test coverage +- Fixed a bunch of issues with osl namespace mgmt + +## 0.3.0 (2015-05-27) + +- Introduce CNM (Container Networking Model) +- Replace docker networking with CNM & Bridge driver diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..577b6c49 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM golang:1.10.2 as dev +RUN apt-get update && apt-get -y install iptables \ + protobuf-compiler + +RUN go get github.com/golang/lint/golint \ + golang.org/x/tools/cmd/cover \ + github.com/mattn/goveralls \ + github.com/gordonklaus/ineffassign \ + github.com/client9/misspell/cmd/misspell \ + honnef.co/go/tools/cmd/gosimple \ + github.com/gogo/protobuf/protoc-gen-gogo + +WORKDIR /go/src/github.com/docker/libnetwork + +FROM dev + +COPY . . diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..e06d2081 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/MAINTAINERS b/MAINTAINERS new file mode 100644 index 00000000..b6474981 --- /dev/null +++ b/MAINTAINERS @@ -0,0 +1,59 @@ +# Libnetwork maintainers file +# +# This file describes who runs the docker/libnetwork project and how. +# This is a living document - if you see something out of date or missing, speak up! +# +# It is structured to be consumable by both humans and programs. +# To extract its contents programmatically, use any TOML-compliant parser. +# +# This file is compiled into the MAINTAINERS file in docker/opensource. +# +[Org] + [Org."Core maintainers"] + people = [ + "abhi", + "aboch", + "ctelfer", + "chenchun", + "fcrisciani", + "mavenugo", + ] + +[people] + +# A reference list of all people associated with the project. +# All other sections should refer to people by their canonical key +# in the people section. + + # ADD YOURSELF HERE IN ALPHABETICAL ORDER + + [people.abhi] + Name = "Abhinandan Prativadi Bayankaram" + Email = "abhi@docker.com" + GitHub = "abhi" + + [people.aboch] + Name = "Alessandro Boch" + Email = "aboch@docker.com" + GitHub = "aboch" + + [people.ctelfer] + Name = "Christopher Telfer" + Email = "chris.telfer@docker.com" + GitHub = "ctelfer" + + [people.chenchun] + Name = "Chun Chen" + Email = "ramichen@tencent.com" + GitHub = "chenchun" + + [people.fcrisciani] + Name = "Flavio Crisciani" + Email = "flavio.crisciani@docker.com" + GitHub = "fcrisciani" + + [people.mavenugo] + Name = "Madhu Venugopal" + Email = "madhu@docker.com" + GitHub = "mavenugo" + diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..325bd9e1 --- /dev/null +++ b/Makefile @@ -0,0 +1,136 @@ +.PHONY: all all-local build build-local clean cross cross-local gosimple vet lint misspell check check-local check-code check-format unit-tests +SHELL=/bin/bash +dockerbuildargs ?= --target dev - < Dockerfile +dockerargs ?= --privileged -v $(shell pwd):/go/src/github.com/docker/libnetwork -w /go/src/github.com/docker/libnetwork +build_image=libnetworkbuild +container_env = -e "INSIDECONTAINER=-incontainer=true" +docker = docker run --rm -it ${dockerargs} $$EXTRA_ARGS ${container_env} ${build_image} +CROSS_PLATFORMS = linux/amd64 linux/386 linux/arm windows/amd64 +PACKAGES=$(shell go list ./... | grep -v /vendor/) +export PATH := $(CURDIR)/bin:$(PATH) + +all: build check clean + +all-local: build-local check-local clean + +builder: + docker build -t ${build_image} ${dockerbuildargs} + +build: builder + @echo "🐳 $@" + @${docker} make build-local + +build-local: + @echo "🐳 $@" + @mkdir -p "bin" + go build -tags experimental -o "bin/dnet" ./cmd/dnet + go build -o "bin/docker-proxy" ./cmd/proxy + CGO_ENABLED=0 go build -o "bin/diagnosticClient" ./cmd/diagnostic + CGO_ENABLED=0 go build -o "bin/testMain" ./cmd/networkdb-test/testMain.go + +build-images: + @echo "🐳 $@" + cp cmd/diagnostic/daemon.json ./bin + docker build -f cmd/diagnostic/Dockerfile.client -t dockereng/network-diagnostic:onlyclient bin/ + docker build -f cmd/diagnostic/Dockerfile.dind -t dockereng/network-diagnostic:17.12-dind bin/ + docker build -f cmd/networkdb-test/Dockerfile -t dockereng/e2e-networkdb:master bin/ + docker build -t dockereng/network-diagnostic:support.sh support/ + +push-images: build-images + @echo "🐳 $@" + docker push dockereng/network-diagnostic:onlyclient + docker push dockereng/network-diagnostic:17.12-dind + docker push dockereng/e2e-networkdb:master + docker push dockereng/network-diagnostic:support.sh + +clean: + @echo "🐳 $@" + @if [ -d bin ]; then \ + echo "Removing binaries"; \ + rm -rf bin; \ + fi + +cross: builder + @mkdir -p "bin" + @for platform in ${CROSS_PLATFORMS}; do \ + EXTRA_ARGS="-e GOOS=$${platform%/*} -e GOARCH=$${platform##*/}" ; \ + echo "$${platform}..." ; \ + ${docker} make cross-local ; \ + done + +cross-local: + @echo "🐳 $@" + go build -o "bin/dnet-$$GOOS-$$GOARCH" ./cmd/dnet + go build -o "bin/docker-proxy-$$GOOS-$$GOARCH" ./cmd/proxy + +check: builder + @${docker} make check-local + +check-local: check-code check-format + +check-code: lint gosimple vet ineffassign + +check-format: fmt misspell + +unit-tests: builder + ${docker} make unit-tests-local + +unit-tests-local: + @echo "🐳 Running tests... " + @echo "mode: count" > coverage.coverprofile + @go build -o "bin/docker-proxy" ./cmd/proxy + @for dir in $$( find . -maxdepth 10 -not -path './.git*' -not -path '*/_*' -not -path './vendor/*' -type d); do \ + if ls $$dir/*.go &> /dev/null; then \ + pushd . &> /dev/null ; \ + cd $$dir ; \ + go test ${INSIDECONTAINER} -test.parallel 5 -test.v -covermode=count -coverprofile=./profile.tmp ; \ + ret=$$? ;\ + if [ $$ret -ne 0 ]; then exit $$ret; fi ;\ + popd &> /dev/null; \ + if [ -f $$dir/profile.tmp ]; then \ + cat $$dir/profile.tmp | tail -n +2 >> coverage.coverprofile ; \ + rm $$dir/profile.tmp ; \ + fi ; \ + fi ; \ + done + @echo "Done running tests" + +# Depends on binaries because vet will silently fail if it can not load compiled imports +vet: ## run go vet + @echo "🐳 $@" + @test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)" + +misspell: + @echo "🐳 $@" + @test -z "$$(find . -type f | grep -v vendor/ | grep "\.go\|\.md" | xargs misspell -error | tee /dev/stderr)" + +fmt: ## run go fmt + @echo "🐳 $@" + @test -z "$$(gofmt -s -l . | grep -v vendor/ | grep -v ".pb.go$$" | tee /dev/stderr)" || \ + (echo "👹 please format Go code with 'gofmt -s -w'" && false) + +lint: ## run go lint + @echo "🐳 $@" + @test -z "$$(golint ./... | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)" + +ineffassign: ## run ineffassign + @echo "🐳 $@" + @test -z "$$(ineffassign . | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)" + +gosimple: ## run gosimple + @echo "🐳 $@" + @test -z "$$(gosimple . | grep -v vendor/ | grep -v ".pb.go:" | grep -v ".mock.go" | tee /dev/stderr)" + +shell: builder + @${docker} ${SHELL} + +# Rebuild protocol buffers. +# These may need to be rebuilt after vendoring updates, so .pb.go files are declared .PHONY so they are always rebuilt. +PROTO_FILES=$(shell find . -path ./vendor -prune -o -name \*.proto -print) +PB_FILES=$(PROTO_FILES:.proto=.pb.go) + +%.pb.go: %.proto + ${docker} protoc -I=. -I=/go/src -I=/go/src/github.com/gogo/protobuf -I=/go/src/github.com/gogo/protobuf/protobuf --gogo_out=./ $< + +.PHONY: protobuf $(PROTO_FILES) +protobuf: builder $(PB_FILES) diff --git a/README.md b/README.md new file mode 100644 index 00000000..981b62bb --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# libnetwork - networking for containers + +[![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) + +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](docs/design.md) 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. + + +```go +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()) +} +``` + +## Future +Please refer to [roadmap](ROADMAP.md) for more information. + +## Contributing + +Want to hack on libnetwork? [Docker's contributions guidelines](https://github.com/docker/docker/blob/master/CONTRIBUTING.md) apply. + +## Copyright and license +Code and documentation copyright 2015 Docker, inc. Code released under the Apache 2.0 license. Docs released under Creative commons. diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 00000000..f2d8a42b --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,20 @@ +# Roadmap + +This document defines the high-level goals of the libnetwork project. See [Project Planning](#project-planning) for information on Releases. + +## Long-term Goal + +libnetwork project will follow Docker and Linux philosophy of delivering small, highly modular and composable tools that work well independently. +libnetwork aims to satisfy that composable need for Networking in Containers. + +## Short-term Goals + +- Modularize the networking logic in Docker Engine and libcontainer in to a single, reusable library +- Replace the networking subsystem of Docker Engine, with libnetwork +- Define a flexible model that allows local and remote drivers to provide networking to containers +- Provide a stand-alone tool "dnet" for managing and testing libnetwork + +Project Planning +================ + +[Project Pages](https://github.com/docker/libnetwork/wiki) define the goals for each Milestone and identify the release-relationship to the Docker Platform. diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..e09e7045 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,58 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +$consul=<