Why docker sleep 1 for continuous background process?

I would like to do “starting a long-running worker process” as in this article
https://docs.docker.com/articles/basics/

I don’t understand why sleep 1? why not sleep 86400??? one day or one year?

  • Ruby OOM in container
  • How to manage code changes in rails with docker
  • Files changes not reflected in Docker image after rebuild
  • Run shell script inside Docker container from another Docker container?
  • Docker container won't access MySQL on host machine
  • Docker - misunderstanding about the execution and volume
  • # Start a very useful long-running process
    $ JOB=$(sudo docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1; done")
    
    # Collect the output of the job so far
    $ sudo docker logs $JOB
    
    # Kill the job
    $ sudo docker kill $JOB
    

    What’s the “best” way to make it run as a background process for apache, nginx, mysql etc?

    Why do you need to echo? is that necessary?

  • supervisord: is it possible to redirect subprocess stdout back to supervisord?
  • Redirect users to different domains of the same web application according to their ip address location
  • How can I use a docker swarm mode manager behind a floating IP
  • Dockerized app throws read operation timed out error and exits
  • Dockerizing PostgreSQL
  • Allow WordPress write access to Docker mounted folder
  • 2 Solutions collect form web for “Why docker sleep 1 for continuous background process?”

    This job is to write Hello world to stdout every second I guess for demonstration purposes only. If you want to do something else at some different interval you have to change it accordingly.

    The key thing is the -d flag makes Docker run it in background (‘detatched’), and the docker logs lets you examine the logs as many times as you like after that point.

    For Apache, get hold of an Apache image; for Nginx use an Nginx image, and so on.

    I found this image with Nginx and PHP, and the official Docker mysql image worked for me. You’ll need to do a bit more reading to see how to integrate your data, web content, config, etc.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.