code: def monitor_docker(
      docker_compose_path: str,
      status_path: str,
      project_name: str,
      update_interval: float = 1.0,
  ):
      while not os.path.exists(docker_compose_path):
          # Wait until cluster is created
          time.sleep(0.5)
  
      print(
          "Docker compose config detected, starting status monitoring"
      )
  
      # Make sure this is always writeable from inside the containers
      os.chmod(docker_compose_path, 0o777)
  
      docker_config = {"force_update": True}
  
      # Force update
      next_update = time.monotonic() - 1.0
      shutdown = False
      status = None
  
      # Loop:
      # If the config changed, update cluster.
      # Every `update_interval` seconds, update docker status.
      while not shutdown:
          new_docker_config = _read_yaml(docker_compose_path)
          if new_docker_config != docker_config:
              # Update cluster
              shutdown = _update_docker_compose(
                  docker_compose_path, project_name, status
              )
  
              # Force status update
              next_update = time.monotonic() - 1.0
  
          if time.monotonic() > next_update:
              # Update docker status
              status = _update_docker_status(
                  docker_compose_path, project_name, status_path
              )
              next_update = time.monotonic() + update_interval
  
          docker_config = new_docker_config
          time.sleep(0.1)
  
      print("Cluster shut down, terminating monitoring script.")
  
file_path: ray/python/ray/autoscaler/_private/fake_multi_node/docker_monitor.py
imports: import argparse
  import json
  import os
  import shutil
  import subprocess
  import time
  from typing import Any, Dict, List, Optional
  import yaml
label_desc: Use image node_id 5 for calling a global function with example usage: monitor_docker(docker_compose_path, status_path, project_name, update_interval) without return types