When you get a shell into the container, the system may run ~/.profile or ~/.bashrc or both.
You can check this out if you add some echo statement in those files to verify which ones run in each case. I did this and here is the result.
Hmm… It works now. But why?
(famous developer quote, I guess)
I mean, in my case (for some reason) there is “bashrc” output too, before actual command output…
UPD:
If I move the NVM related lines to the top of ~/.bashrc it works too. I wonder if it possible to wait until the ~ / .bashrc file has finished executing and only then execute the command specified in exec (it would be more general solution to this case I think)
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
That is the reason why .bashrc is not meant to run when the shell is not interactive.
In my case, I added the echo line at the very end of the .bashrc file, hence they did not run when the shell was non-interactive. If you added your echo at the very beginning, then you got the echo as well.
In terms of Unix/Linux semantics, it is suitable to add and $PATH changes to the end of the .profile. As you can see, this file already has other cases with additions to the $PATH.