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 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 file as soon as the container tty appears.

How do I accomplish this?

(Ranjandas) #2


You can do something like this.

# Dockerfile
FROM centos:6

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

Then build docker image and run.


(Kerwood) #3

Perfect!.. Works like a charm :smiley: