I am looking to run multiple instances of my docker container, and have each container re-run every 30 minutes.

I have a conf file in a src directory the docker container needs to pull from to be able to run. For example


docker run -v ~/example.com/conf:/opt/tool/conf --rm -it sdok

Where example.com/conf: is the place the container will need to pull the conf file from in order to run.

I have multiple example.com directories... 3-4 of them.

My bash script would look something like:


cd /home
docker run -v ~/example.com/conf:/opt/tool/conf --rm -it sdok
docker run -v ~/example.com1/conf:/opt/tool/conf --rm -it sdok
docker run -v ~/example.com2/conf:/opt/tool/conf --rm -it sdok
docker run -v ~/example.com3/conf:/opt/tool/conf --rm -it sdok
docker run -v ~/example.com4/conf:/opt/tool/conf --rm -it sdok

After, I would just cron the sdok.sh script and let it run every 30 minutes. Is there a better way to do this?

*/30 * * * * cd /home/wraiith75/bugbounty/tool/example.com && ./sdok.sh

Please let me know, thanks!

  1. Why -it? -d would be more appropriate
  2. With --rm you lose the logs, and won't have a clue in case of problems.
  3. Using a docker-compose file instead of a script could be better (you keep restarting the same containers, and keep the logs)
  4. If you keep the bash script you can write it as a loop over your example.com* directories.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.