Giter Site home page Giter Site logo

TODO List about crs HOT 2 CLOSED

wrfly avatar wrfly commented on August 23, 2024
TODO List

from crs.

Comments (2)

wrfly avatar wrfly commented on August 23, 2024

## without jq

IP:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'

MAC:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}'

Binds:
docker inspect --format='{{range .HostConfig.Binds}}{{.}}{{end}}'

ALL:
docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}|{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}|{{range .HostConfig.Binds}}{{.}}{{end}}'


# ID -> veth
function veth_interface_for_container() {
    # Get the container's IP:
    local IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "${1}")
    local IP=$(echo "${IP}" | cut -d " " -f1)

    # Ping this IP to get its MAC:
    ping -c 1 "${IP}" &> /dev/null

    # Get the bridge interface via arp:
    local bridge=$(arp -n | grep "${IP}" | tr -s " " " " | cut -d " " -f5)

    # Get veth:
    ip link show | grep "${bridge}" | cut -d " " -f2 | tr -d ":" | tail -1 | cut -d"@" -f1
}

# veth -> ID
function get_container_from_veth() {
  # Get its bridge interface
  local br=$(ip link show "${1}" | head -1 | cut -d " " -f 9)

}

from crs.

wrfly avatar wrfly commented on August 23, 2024

process -> containerID

get process nets(inode): readlink /proc/42227/ns/net | sed "s/.*\[\(.*\)\]/\1/g"

get the network id: ls -li /run/docker/netns | grep 4026533503, aka sandboxKey

from crs.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.