Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO List #1

Closed
1 of 6 tasks
wrfly opened this issue Jul 18, 2018 · 2 comments
Closed
1 of 6 tasks

TODO List #1

wrfly opened this issue Jul 18, 2018 · 2 comments

Comments

@wrfly
Copy link
Owner

wrfly commented Jul 18, 2018

  • query IP

  • mount dir|file

  • network device

  • ...

  • transfer images between registries

  • sync image info to files and directories

@wrfly
Copy link
Owner Author

wrfly commented Jul 18, 2018


## 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)

}

@wrfly
Copy link
Owner Author

wrfly commented Jul 18, 2018

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

@wrfly wrfly closed this as completed Jul 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant