How come the following, i.e. echoing
$PATH directly from
docker exec -i -t my_container bash -c "echo $PATH"
returns a different value for
$PATH than what follows, i.e. starting an interactive bash session and echoing the
docker exec -i -t my_container bash root@21e6d898c3c2:/# echo $PATH
To give some context to this question, I'd like to run a command in the container with
docker exec, and this command is on the path if I start an interactive bash session, but isn't if I just run the command.
Using the full path of the executable isn't a workaround in this case, as the command relies on other environment variables that, just like
PATH are set in a bash interactive session, but not if I run the command up straight.