Docker 和 .bash_history [英] Docker and .bash_history
问题描述
有没有办法与 docker 容器共享 .bash_history
卷,这样每次我进入 shell 时,我的 bash 历史记录都可以滚动浏览?
如果能用 IPython 做同样的事情,那就太棒了.
docker run --rm -it -v ~/.bash_history:/root/.bash_history ubuntu/bin/bash
<块引用>
这会将您放入新容器中的 bash shell,您将获得来自主机的 bash 历史记录,当您退出容器时,主机将获得键入的命令的历史记录,而在容器中.
Is there any way to share a .bash_history
volume with a docker container so that everytime I go into a shell I have my bash history available for scrolling through?
Would be awesome to be able to do the same thing with IPython too.
It is the example from the 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.
这篇关于Docker 和 .bash_history的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!