Docker and .bash_history Docker and .bash_history bash bash

Docker and .bash_history


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.


In your docker-compose.override.yml:

version: '2'services:  whatever:        volumes:      -       - ~/.bash_history:/root/.bash_history


To keep IPython history, you can set the IPYTHONDIR environment variable to somewhere within your mapped volume.

The docker-compose.override.yml would look like this:

version: '2'services:  some-service:    environment:      - IPYTHONDIR=/app/.ipython    volumes:      - .:/app