Skip to content

Instantly share code, notes, and snippets.

@fabiand
Created May 11, 2015 10:10
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 fabiand/04b41c0a9fb24c023297 to your computer and use it in GitHub Desktop.
Save fabiand/04b41c0a9fb24c023297 to your computer and use it in GitHub Desktop.
docker-pid() { docker inspect --format="{{.State.Pid}}" $1 ; }
DSTCT=${1}
DSTPID=$(docker-pid $DSTCT)
UNCONNECTEDETH=$(nmcli -t -f device,type,connection device | egrep "ethernet:--$" | cut -d ":" -f1)
for NIC in $UNCONNECTEDETH
do
echo "Moving '$NIC' to netns of '$DSTPID'"
ip link set netns ${DSTPID} $NIC
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment