Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Created July 22, 2014 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbrl/363d06afb0524aa6ab8c to your computer and use it in GitHub Desktop.
Save jeffbrl/363d06afb0524aa6ab8c to your computer and use it in GitHub Desktop.
Bring up IPv6-enabled docker container
#!/bin/bash
#
# Jeff Loughridge
# July 2014
# jeffl at brooksconsulting-llc.com
# first argument to script must be IPv6 address from DO-allocated
# space that is not part of the first /126 (e.g. 0x4 to 0xF as last
# hex character
IPV6_ADDRESS=$1
if [ -z "$IPV6_ADDRESS" ]; then
echo "please specify IPv6 address for container's eth0"
exit 1
fi
echo "container eth0: $IPV6_ADDRESS"
# get docker0's link local address
LINK_LOCAL=$( \
ip addr show docker0 | \
grep "inet6 fe80" | \
awk '{print $2}' | \
sed 's/\/.*//' \
)
echo "docker0 link local: $LINK_LOCAL"
docker run -i -t \
--lxc-conf="lxc.network.flags = up" \
--lxc-conf="lxc.network.ipv6 = $IPV6_ADDRESS/126" \
--lxc-conf="lxc.network.ipv6.gateway = $LINK_LOCAL" busybox:ubuntu-14.04 /bin/sh
@harkleycod
Copy link

Very good.

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