I wonder how I get an Environment variable from docker inspect.
when i run
docker inspect -f \"{{.Config.Env.PATH}} \" 1e2b8689cf06
docker inspect --format='{{range .Config.Env}}{{println .}}{{end}}' CONTAINER-NAME | grep -P "^YOUR_VAR=" | sed 's/[^=]*=//'
This solution requires grep(with -P option), sed and ability to pipeline them but solves 2 problems which most of the other solutions do not.
Firstly, it performs exact match on variable name. For example if you have following variables:
YOUR_VAR=value
ANOTHER_YOUR_VAR=value2
OTHER_VAR=YOUR_VAR
You will properly receive value.
Secondly, it properly handles cases where variable value contains = characters. For example:
REBEL_OPTS=-Drebel.stats=false
Will properly get you -Drebel.stats=false instead of false.