Skip to content

Instantly share code, notes, and snippets.

@mdobson
Last active December 31, 2015 08:59
Show Gist options
  • Select an option

  • Save mdobson/7964426 to your computer and use it in GitHub Desktop.

Select an option

Save mdobson/7964426 to your computer and use it in GitHub Desktop.
Create docker bridge for API within container

##Use network interfaces to allow docker to speak to it's API via containers

###Daemon and host side config

  1. Add a new network hardware called api0 ip link add api0 type bridge
  2. Bring it up using ip link set api0 up
  3. Give it an IP Address ip addr add 192.168.0.1/16 dev api0
  4. Restart docker daemon on that IP address docker -d -H 192.168.0.1:4243 -d

###Docker side config lxc containers can have more than one network interface at startup. So we can just add raw lxc configs to make that link between them.

  1. Use the following docker command to start a container with the second link to the api0 interface

docker -H 192.168.0.1:4243 run -d -lxc-conf="lxc.network.type=veth" -lxc-conf="lxc.network.link=api0" -lxc-conf="lxc.network.flags=up" -lxc-conf="lxc.network.ipv4=192.168.0.2/16" -lxc-conf="lxc.network.name=api0" -p 22 dhrp/sshd /usr/sbin/sshd -D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment