Docker Community Forums

Share and learn in the Docker community.

[SOLVED] Run bash script on login - Interactive


(Kerwood) #1

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?


(Ranjandas) #2

Hi,

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.

Regards


(Kerwood) #3

Perfect!.. Works like a charm :smiley:
Thanks