https://github.com/rootsongjc/docker-ipam-plugin
Docker network plugin to make a L2 flat network.
https://github.com/rootsongjc/docker-ipam-plugin
docker
Last synced: about 1 year ago
JSON representation
Docker network plugin to make a L2 flat network.
- Host: GitHub
- URL: https://github.com/rootsongjc/docker-ipam-plugin
- Owner: rootsongjc
- Created: 2016-06-14T07:11:31.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T03:27:08.000Z (about 9 years ago)
- Last Synced: 2025-06-09T01:59:39.641Z (about 1 year ago)
- Topics: docker
- Language: Go
- Size: 749 KB
- Stars: 14
- Watchers: 5
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker custom network plugin
#### Overview
Create a new docker custom network named "mynet" with a bridge br0.
Docker container allocated on different hosts which started with "mynet" can be assgined a IP address by yourself or automated assgined so that the containers can be accessed by each others and the hosts.
#### Design
Feature
1.IP manager
All IP addressed stored in ectd. The plugin create a unix socker - /var/run/docker/plugins/talkingdata.sock. Docker invoke the socket when users communcate with docker everytime.
2.Create network
Create a network configuration file on /etc/sysconfig/network-scripts/ifcfg-br0, restart network it works.
For example:
```
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=10.10.0.85
GATEWAY=10.10.0.1
NETMASK=255.255.192.0
ONBOOT=yes
NOZEROCONF=yes
IPV6INIT=no
NM_CONTROLLED=no
DELAY=0
```
#### Usage
Enviromnent
Docker: 1.11.1
OS: CentOS7.1
Gateway: 172.16.16.1
Host network IP range: 172.16.20.54/20 - 172.16.20.58/20
Build the project and put it at /usr/bin/docker-ipam-plugin
Etcd cluster: http://172.16.20.53:2379,http://172.16.20.54:2379,http://172.16.20.55:2379
1. Assign host IP
docker-ipam-plugin --cluster-store=http://172.16.20.53:2379,http://172.16.20.54:2379,http://172.16.20.55:2379 host-range --ip-start 172.16.20.54/20 --ip-end 172.16.20.58/20 --gateway 172.16.16.1
2. Assign docker IP
docker-ipam-plugin --cluster-store=http://172.16.20.53:2379,http://172.16.20.54:2379,http://172.16.20.55:2379 ip-range --ip-start 172.16.21.100/20 --ip-end 172.16.21.200/20
3. Run docker ipam plugin
nohup docker-ipam-plugin --debug=true --cluster-store=http://172.16.20.53:2379,http://172.16.20.54:2379,http://172.16.20.55:2379 server 2>&1 >> /var/log/docker-ipam-plugin.log &
4. Create custom network
docker-ipam-plugin --cluster-store=http://172.16.20.53:2379,http://172.16.20.54:2379,http://172.16.20.55:2379 create-network --ip 172.16.20.54
#### Info
- Usage: docker-ipam-plugin --help
- cluster-store defualt http://127.0.0.1:2379
- Open debug mode for more information
- Docker will choose a random IP address from etcd IP range if you run a docker contianer wihtout assign a specific IP.
#### Reference
https://docs.docker.com/engine/extend/plugins
https://github.com/docker/libnetwork/blob/master/docs/ipam.md
https://github.com/docker/go-plugins-helpers