How to .bashrc for root in Docker

Turns out I was adding the file incorrectly. It should be /root/.bashrc rather than just .bashrc. With the file added in the correct place, no run command or CMD is required.

Build

...
ADD iptables /iptables
RUN touch /root/.bashrc \
 && cat iptables >> /root/.bashrc
...

Run

docker run -it --cap-add=NET_ADMIN myImage /bin/bash

Leave a Comment