I want to create a shell script function that runs this:
docker inspect 5914ba2819d6 | jq '.[0].NetworkSettings.Networks["foo"].IPAddress'
I'm trying to get the function to run like:
getcontainerip 5914ba2819d6 foo
I've edited .bash_profile to have many permutations like this:
getcontainerip() {
docker inspect "$1" | jq '.[0].NetworkSettings.Networks["$2"].IPAddress'
}
No matter what, the literal double quotes never get added surrounding the second parameter. The output will either be blank (because the double quotes aren't there), or a syntax error:
jq: error: syntax error, unexpected '$' (Unix shell quoting issues?)
How do I get the literal double quotes to surround the second parameter? Thanks.