启动交互式Docker会话时的源bash配置文件



运行此程序以交互方式打开bash:

docker exec-it bash

然而,它并不是源~/.bash_profile,即容器中的bash_profile。我最后尝试了bash -i而不是bash,但不起作用。那么,如何在进入容器时进行配置文件加载,就像在常规交互shell中一样?

将其添加到容器用户.bashrc:

if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi

您需要重新生成映像并复制.bash_profile文件。

-l工作,正如@chepner在评论中提到的:

docker exec-it bash-l

最新更新