Docker Community Forums

Share and learn in the Docker community.

How to auto run some script?

dockercloud

(Alceatraz) #1

Hello every one,

Here is what I want get :

I want to run some jar in docker , and here is my question :

docker run -v /java:/java --name java-docker docker  /java/run.sh

This is obviously work.

But after restart , You can’t do this like that :

docker start java-docker /java/run.sh

So , Here is that I think:

Use some way to modify the docker let it run script when use this command

docker start java-docker

And it similar with DockerFile command : CMD

CMD "/java/run.sh"

So how to do this without commit a new image ( modify “CMD” for a container) ? or this is impossible ?

Or I can do this by some other way ?

Tips: the /java will gen by script , the run.sh will create with different index


(Think) #2

try to minimize the lifetime of containers. don’t stop and restart them. just create a new one if you need a new one with your new command to run.