code: def docker_services(
      tmp_path_factory,
      docker_compose_command,
      docker_compose_file,
      docker_compose_project_name,
      docker_setup,
  ):
      from filelock import FileLock
      from pytest_docker.plugin import DockerComposeExecutor, Services
  
      if os.environ.get("CI") and os.name == "nt":
          pytest.skip("disabled for Windows on CI")
  
      try:
          subprocess.check_output(
              "docker ps",  # noqa: S607
              stderr=subprocess.STDOUT,
              shell=True,  # noqa: S602
          )
      except subprocess.CalledProcessError as err:
          out = (err.output or b"").decode("utf-8")
          pytest.skip(
              f"docker is not installed or the daemon is not running: {out}"
          )
  
      try:
          cmd = "docker-compose version"
          subprocess.check_output(
              cmd,
              stderr=subprocess.STDOUT,
              shell=True,  # noqa: S602
          )
      except subprocess.CalledProcessError as err:
          out = (err.output or b"").decode("utf-8")
          pytest.skip(f"docker-compose is not installed: {out}")
  
      executor = DockerComposeExecutor(
          docker_compose_command,
          docker_compose_file,
          docker_compose_project_name,
      )
  
      # making sure we don't accidentally launch docker-compose in parallel,
      # as it might result in network conflicts. Inspired by:
      # https://github.com/pytest-dev/pytest-xdist#making-session-scoped-fixtures-execute-only-once
      lockfile = (
          tmp_path_factory.getbasetemp().parent / "docker-compose.lock"
      )
      with FileLock(os.fspath(lockfile)):
          executor.execute(docker_setup)
          # note: we are not tearing down the containers here
          return Services(executor)
  
imports: import os
  import pathlib
  import subprocess
  from typing import Dict, Tuple
  import pytest
  from .scripts import copy_script
label_desc: Use image node_id 21 for calling a global function with example usage: docker_services(tmp_path_factory, docker_compose_command, docker_compose_file, docker_compose_project_name, docker_setup) and returns: Services