I wonder how I get an Environment variable from docker inspect.
when i run
docker inspect -f \"{{.Config.Env.PATH}} \" 1e2b8689cf06
A very convenient option that doesn't require any external tools is:
docker exec 1e2b8689cf06 sh -c 'echo $PATH'
Admittedly this is not using docker inspect
, but still..
I find it better to parse for the environment variable name your interested than relying on index.
echo $(docker inspect --format '{{ .Config.Env }}' mysql) | tr ' ' '\n' | grep MYSQL_ROOT_PASSWORD | sed 's/^.*=//'