Open ruebenramirez opened 7 years ago
I suppose I could have also just grabbed the IP assigned to the docker0 interface via ifconfig + grep + awk ^2
/sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'
source: http://www.if-not-true-then-false.com/2010/linux-get-ip-address/
or using python:
curl -s http://www.telize.com/geoip/46.19.37.108 | python -c 'import sys, json; print json.load(sys.stdin)["country"]'
source: http://www.cambus.net/parsing-json-from-command-line-using-python/
definitely liking jq's portable c binary over importing packages to filter json via cli though.
I wanted to quickly grab the default gateway from the docker bridge device in order to reference the docker host. The docker command provides enough info to give us this back!
which gives us back a whole bunch of json:
I found an excellent utility to parse json on the command line: https://stedolan.github.io/jq/. They even have a web shell to learn the jq syntax to grab elements from your own json: https://jqplay.org/
to dynamically source the gateway address from the docker bridge device we can use this
jq
query:results in providing just the gateway IP value: