gpt4 book ai didi

bash - Docker 和 .bash_history

转载 作者:IT老高 更新时间:2023-10-28 12:37:25 27 4
gpt4 key购买 nike

有没有办法与 docker 容器共享 .bash_history 卷,这样每次我进入 shell 时,我的 bash 历史记录都可以滚动浏览?

如果能用 IPython 做同样的事情,那就太棒了。

最佳答案

这是 documentation about volume: Mount a host file as a data volume 中的示例:

docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu /bin/bash

This will drop you into a bash shell in a new container, you will have your bash history from the host and when you exit the container, the host will have the history of the commands typed while in the container.

关于bash - Docker 和 .bash_history,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28279862/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com