Docker 和 .bash_history [英] Docker and .bash_history

查看:24
本文介绍了Docker 和 .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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆