Execute local shell script using docker run interactive

  docker

Can I execute a local shell script within a docker container using docker run -it ?

Here is what I can do:

$ docker run -it 5ee0b7440be5                                                                                                                                                                                                                           
bash-4.2# echo "Hello"
Hello
bash-4.2# exit
exit

I have a shell script on my local machine

hello.sh:

echo "Hello"

I would like to execute the local shell script within the container and read the value returned:

$ docker run -it 5e3337440be5 #Some way of passing a reference to hello.sh to the container.
Hello                                                                                                                                                                                                                     

Source: Docker Questions

LEAVE A COMMENT