Add static IP command line switch (#12)

* Add static IP command line switch

There are use cases in which a container needs a persistent static IP.
This patch adds a switch to set a static IP for a container.


"hooks": {
                "prestart": [
                        	"path": "/home/example/go/src/",
                        	"args": ["netns", "--static-ip", ""]

* Fix create network test arguments
3 files changed
tree: ada9ac9bdd8e8e05e2a1948f47fc4b2221612199
  1. .gitignore
  2. .goosarch
  3. .travis.yml
  4. .traviskey
  5. Dockerfile
  7. Makefile
  9. VERSION.txt
  11. bridge/
  12. create.go
  13. go.mod
  14. go.sum
  15. list.go
  16. main.go
  17. netutils/
  18. network/
  19. remove.go
  20. vendor/
  21. version/


Travis CI GoDoc Github All Releases

Runc hook for setting up default bridge networking.



For installation instructions from binaries please visit the Releases Page.

Via Go

$ go get


$ netns -h
netns -  Runc hook for setting up default bridge networking.

Usage: netns <command>


  --ipfile     file in which to save the containers ip address (default: .ip)
  --mtu        mtu for bridge (default: 1500)
  --state-dir  directory for saving state, used for ip allocation (default: /run/
  --bridge     name for bridge (default: netns0)
  -d           enable debug logging (default: false)
  --iface      name of interface in the namespace (default: eth0)
  --ip         ip address for bridge (default:


  create   Create a network.
  ls       List networks.
  rm       Delete a network.
  version  Show the version information.

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          netnsv0-21635       21635               running          netnsv0-21835       21835               running          netnsv0-22094       22094               running          netnsv0-25996       25996               running