Runc hook (OCI compatible) for setting up default bridge networking for containers.

Clone this repo:
  1. 5d5c496 update README.md by Jess Frazelle · 2 days ago master
  2. 74967ff fix travis by Jess Frazelle · 6 days ago
  3. 6d5bafc Bump version to v0.3.0 by Jess Frazelle · 8 weeks ago v0.3.0
  4. 3cd7d74 update vendor by Jess Frazelle · 8 weeks ago
  5. b34e4b2 update generated project files by Jess Frazelle · 8 weeks ago

netns

Travis CI

Runc hook for setting up default bridge networking.

Installation

Binaries

Via Go

$ go get github.com/jessfraz/netns

Usage

$ netns --help
            _
 _ __   ___| |_ _ __  ___
| '_ \ / _ \ __| '_ \/ __|
| | | |  __/ |_| | | \__ \
|_| |_|\___|\__|_| |_|___/

 Runc hook for setting up default bridge networking.
 Version: v0.3.0

 Netns provides the following commands. Usage format:

    netns [-flag value] [-flag value] command

  Where command is one of:

    createbr, delbr, [ls|list], delete

  If command is blank (e.g. when called via a hook) it
  will create a network endpoint in the expected net
  namespace details for that PID.

  -bridge string
        name for bridge (default "netns0")
  -d    run in debug mode
  -iface string
        name of interface in the namespace (default "eth0")
  -ip string
        ip address for bridge (default "172.19.0.1/16")
  -ipfile string
        file in which to save the containers ip address (default ".ip")
  -mtu int
        mtu for bridge (default 1500)
  -state-dir string
        directory for saving state, used for ip allocation (default "/run/github.com/jessfraz/netns")
  -v    print version and exit (shorthand)
  -version
        print version and exit

Place this in the Hooks.Prestart field of your runc config.

{
    ...
    "hooks": {
        "prestart": [
            {
                "path": "/path/to/netns"
            }
        ]
    },
    ...
}

List network namespaces

$ sudo netns ls
IP                  LOCAL VETH          PID                 STATUS
172.19.0.3          netnsv0-21635       21635               running
172.19.0.4          netnsv0-21835       21835               running
172.19.0.5          netnsv0-22094       22094               running
172.19.0.6          netnsv0-25996       25996               running