Files
containernetworking-plugins/scripts/priv-net-run.sh
Eugene Yakubovich b2d9801b25 Do not use netns as ID or for entropy
ContainerID is now required so use that
or generate random bytes.

Fixes #5
2015-05-08 15:02:23 -07:00

21 lines
420 B
Bash
Executable File

#!/bin/bash -e
# Run a command in a private network namespace
# set up by CNI plugins
contid=$(printf '%x%x%x%x' $RANDOM $RANDOM $RANDOM $RANDOM)
netnspath=/var/run/netns/$contid
ip netns add $contid
ip netns exec $contid ip link set lo up
./exec-plugins.sh add $contid $netnspath
function cleanup() {
./exec-plugins.sh del $contid $netnspath
ip netns delete $contid
}
trap cleanup EXIT
ip netns exec $contid $@