diff --git a/README.md b/README.md index f44f8ce..4968c3e 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,13 @@ Docker implemented in around 100 lines of bash. The following packages are needed to run bocker. +* [bridge-utils][] * btrfs-progs * curl * iproute2 * iptables * libcgroup-tools +* [procps][] * util-linux >= 2.25.2 * coreutils >= 7.5 @@ -24,9 +26,6 @@ Because most distributions do not ship a new enough version of util-linux you wi Additionally your system will need to be configured with the following: * A btrfs filesystem mounted under `/var/bocker` -* A network bridge called `bridge0` and an IP of 10.0.0.1/24 -* IP forwarding enabled in `/proc/sys/net/ipv4/ip_forward` -* A firewall routing traffic from `bridge0` to a physical interface. For ease of use a Vagrantfile is included which will build the needed environment. @@ -142,3 +141,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . + +[bridge-utils]: http://sourceforge.net/projects/bridge/ +[procps]: http://procps.sourceforge.net/ diff --git a/bocker b/bocker index ca77486..d955865 100755 --- a/bocker +++ b/bocker @@ -63,15 +63,20 @@ function bocker_run() { #HELP Create a container:\nBOCKER run /dev/null || ( + brctl addbr bridge0 + ip addr add 10.0.0.1/24 dev bridge0 + ip link set dev bridge0 up + iptables -t nat -A POSTROUTING -s 10.0.0.0/24 ! -o bridge0 -j MASQUERADE + ) ip link add dev veth0_"$uuid" type veth peer name veth1_"$uuid" - ip link set dev veth0_"$uuid" up - ip link set veth0_"$uuid" master bridge0 + ip link set dev veth0_"$uuid" up master bridge0 ip netns add netns_"$uuid" ip link set veth1_"$uuid" netns netns_"$uuid" ip netns exec netns_"$uuid" ip link set dev lo up - ip netns exec netns_"$uuid" ip link set veth1_"$uuid" address 02:42:ac:11:00"$mac" ip netns exec netns_"$uuid" ip addr add 10.0.0."$ip"/24 dev veth1_"$uuid" - ip netns exec netns_"$uuid" ip link set dev veth1_"$uuid" up + ip netns exec netns_"$uuid" ip link set dev veth1_"$uuid" up address 02:42:ac:11:00"$mac" ip netns exec netns_"$uuid" ip route add default via 10.0.0.1 btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$uuid" > /dev/null echo 'nameserver 8.8.8.8' > "$btrfs_path/$uuid"/etc/resolv.conf