Moby: How to load a bashrc config in a container

Created on 11 Sep 2013  路  3Comments  路  Source: moby/moby

Hi,

I just got started playing with Docker and I was wondering what was the best way to get a custom bashrc file loaded every time in a container. Either in every container or per container.

Thanks!

Most helpful comment

Giving that .bashrc is in the image, you can also use /bin/bash -l

All 3 comments

If #1757 gets merged you'll be able to do something like docker run -i -t -v ~/.bashrc:~/.bashrc ubuntu bash. Until then, just make sure ~/.bashrc exists when the container is started:

$ docker run -d ubuntu bash -c "echo 'export foo=bar' > .bashrc"
29b2ebb155e3
$ docker commit 29b2ebb155e3 mybase
e39a1d44ad80
$ docker run -i -t mybase bash
root@2ad5a06af680:/# echo $foo
bar
root@2ad5a06af680:/#

Giving that .bashrc is in the image, you can also use /bin/bash -l

Thanks a lot. I was confused that the loaded .bashrc was /.bashrc and not /root/.bashrc.

Was this page helpful?
0 / 5 - 0 ratings