bash - 启动交互式 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 文件。
推荐阅读
- c - 有充分的理由为什么在 C 中必须将 * 放在每个指针变量之前?
- neo4j - neo4j 在尝试协调数据库时遇到错误
- php - 当 curl 和 Postman 完全正常时,Guzzle 错误“调用 null 时的成员函数 getStatusCode()”
- java - 如何将数据从活动传递到android中的回收器视图适配器
- python - Python Flask avro 请求问题
- php - Laravel 在 null 上调用成员函数 first()
- javascript - classList 的 JavaScript 问题
- python - 有谁知道如何更改函数,以便仅将生成的列表输出到 csv,而 df 中的每一行都不会被范围内的数字分割?
- jboss - 当我有 1000 多个规则时,如何优化我的 Kiebase 构建时间?
- python - 尝试使用 Scrapy 抓取时出现 555 HTTP 协议