Skip to content

Docker exec display the wrong $PATH in non-interactive command [closed]

Why is it that when I execute a non-interactive command using the following syntax:

docker exec -t flexsite /bin/bash -c "echo ${PATH}"

it displays the path from my host operating system?

However, when I log in interactively using:

docker exec -it flexsite /bin/bash

and then execute echo $PATH on the server, it correctly displays the server’s path.”