Docker和.bash_history [英] Docker and .bash_history

查看:129
本文介绍了Docker和.bash_history的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法与docker容器共享一个 .bash_history 卷,这样每当我进入一个shell我有我的bash历史可以滚动? p>

可以使用IPython也能做同样的事情。

解决方案

这是来自有关卷的文档:将主机文件作为数据卷安装

  docker运行--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天全站免登陆