I'm trying to run a command having a $()
as an argument (no sure what that's called) that should be evaluated in a Docker container. For example:
docker exec mycontainer echo $(whoami)
When this is executed, whoami
is run first, on the host machine, and so the host machine's user gets inserted. Instead, I would like the whoami
command to be evaluated in the container such that the container's user is echo'd.
I found it very difficult to find any help on this. Alternatives I've tried that didn't work:
docker exec mycontainer 'echo $(whoami)'
docker exec mycontainer echo '$(whoami)'
docker exec mycontainer echo $$(whoami)
docker exec mycontainer echo \$(whoami)
How can this be achieved?