Why docker sleep 1 for continuous background process?

I would like to do “starting a long-running worker process” as in this article

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

  • running java applications in docker with jboss or tomcat server
  • Why do Docker official images not use USER as required by “best practices”
  • How to combine a Nginx and a NodeJS Docker container
  • Docker run on sub domains
  • How does one specify a particular cipher suite for a nginx docker instance?
  • The easiest way to config docker container log to specific file
  • # 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?

  • Docker user namespacing map user in container to host
  • How can I read data from another data bucket with Google Datalab ipython notebook?
  • How can I improve the performance of my Boot2Docker vm
  • Docker: php7.0-fpm Executable file not found in $PATH
  • How to SSH to docker container in kubernetes cluster?
  • how to get a jar build in docker maven to my local repository
  • 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.