If I understand your question correctly then you want the same shell with the same config in your docker container as in your host system.
You can indeed couple them by using volumes but to get it will be hard and messy to make it work 100% correct. I would strongly suggest installing it and copying the config from your host.
Let's assume on your host you use
bash as shell and you want to use a container created from the the image
foo:latest that is based on ubuntu.
In that case you can create the following
RUN apt-get update && apt-get -y install bash
COPY .bashrc /root/.bashrc
COPY .profile /root/.profile
- Create a dir
.profile from your homedir to this dir
- Go to this dir and run
docker build -t foo:withbash
And you will now have a image
foo:withbash that is the same as
foo:latest but it will also have bash with it's configuration on your host system.
(The same trick can be done for
zsh and other shells and centos and other distributions but the commands in the Dockerfile will be slightly different)
- In my dockerfile I assume that you will be root in your container (which is usually the case). If you are not root in this container you'll probably want to change the last 2 lines so that these files are being copied to the correct dir.
- The 2nd line will work for all dockerimages based on debian, ubuntu or similar distribution.
If it's based on CentOS or similar distribution you'll want :
yum -y update && yum -y install bash
If it's based on Alpine you'll want
RUN apk add --no-cache bash
- If you want zsh change
zsh on the 2nd and 3th line