[SOLVED] Run bash script on login - Interactive

I am new to Docker and trying to make an image.
I’ve made a README.sh file with instructions on how to use the scripts I’ve made, inside the container.
When running the container in interactive mode, like so: docker -i -t image /bin/bash, I want to run the README.sh file as soon as the container tty appears.

How do I accomplish this?


You can do something like this.

# Dockerfile
FROM centos:6

ADD README.sh /usr/local/bin
RUN chmod +x /usr/local/bin/README.sh
RUN echo "sh /usr/local/bin/README.sh" >> /root/.bashrc

Then build docker image and run.


1 Like

Perfect!.. Works like a charm :smiley: