Taken from https://stackoverflow.com/a/60830947/282601
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/bash export containers=$(docker ps --format "{{.ID}}|{{.Names}}") export interfaces=$(ip ad); for x in $containers do export name=$(echo "$x" |cut -d '|' -f 2); export id=$(echo "$x"|cut -d '|' -f 1) export ifaceNum="$(echo $(docker exec -it "$id" cat /sys/class/net/eth0/iflink) | sed s/[^0-9]*//g):" export ifaceStr=$( echo "$interfaces" | grep $ifaceNum | cut -d ':' -f 2 | cut -d '@' -f 1); echo -e "$name: $ifaceStr"; done |
$ container-network-interfaces srh_typo3_1: vethef4413b srh_minio-prod-mirror_1: veth01332cc srh_mariadb_1: vethcb320d8 srh_redis_1: veth9c948d5 srh_minio_1: veth9f86dda