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?

  • Docker cloning - permission denied
  • How to list all the commands that executed on a pulled Docker image?
  • Address docker container by name when net=“host”
  • What does set -e and exec “$@” do for docker entypoint scripts?
  • Cannot finde module 'express' (node app with docker)
  • How do I build docker images without docker?
  • # 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?

  • Public IP mapping to internal shared virtual ip address in Docker
  • Docker Swarm Service - force update of latest image already running
  • How to make a docker image with a populated database for automated tests?
  • Run tests using Jenkins in a Docker Container
  • Keepalived/Haproxy docker-compose connection refused
  • Docker run cron jobs in parallel
  • 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.