Last active
October 28, 2016 21:28
-
-
Save gg7/7fa78518dec7cc2db7b7f522ee463c0f to your computer and use it in GitHub Desktop.
Retrive Docker container network veth pair device on host machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
# set -o noclobber | |
# set -o xtrace | |
cd -- "$(dirname "$0")" | |
container_id=$1 | |
net_ns=$(docker inspect --format='{{.NetworkSettings.SandboxKey}}' "$container_id") | |
peer_ifindex=$(nsenter --net="$net_ns" -- ethtool -S eth0 | grep -Po '(?<=peer_ifindex:\s)\d+') | |
ip link | grep -A1 "^$peer_ifindex:" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment