Docker Community Forums

Share and learn in the Docker community.

How to configure dockerfile so different script is run when the container is started

(Ravim456) #1

I am using CMD to start a process when the container is run. I know how to pass arguments to the container when I run. Is there a way to configure the dockerfile so different scripts are run based on the argument or based on the container name?

Something like
if ARG=script1
CMD exec 'script1’
CMD exec 'script2’

(Dvohra) #2

Run the .sh script in a shell, for example
RUN /bin/bash -c “source /usr/local/bin/”