Skip to content

Instantly share code, notes, and snippets.

@gg7
Last active October 28, 2016 21:28
Show Gist options
  • Save gg7/7fa78518dec7cc2db7b7f522ee463c0f to your computer and use it in GitHub Desktop.
Save gg7/7fa78518dec7cc2db7b7f522ee463c0f to your computer and use it in GitHub Desktop.
Retrive Docker container network veth pair device on host machine
#!/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