code: def container_run(
      platform: str,
      nvidia_runtime: bool,
      docker_registry: str,
      shared_memory_size: str,
      local_ccache_dir: str,
      command: List[str],
      environment: Dict[str, str],
      dry_run: bool = False,
  ) -> int:
      """Run command in a container"""
      # set default environment variables
      environment.update(
          {
              "CCACHE_MAXSIZE": "500G",
              "CCACHE_TEMPDIR": "/tmp/ccache",  # temp dir should be local and not shared
              "CCACHE_DIR": "/work/ccache",  # this path is inside the container as /work/ccache is mounted
              "CCACHE_LOGFILE": "/tmp/ccache.log",  # a container-scoped log, useful for ccache verification.
          }
      )
      environment.update(
          {
              k: os.environ[k]
              for k in ["CCACHE_MAXSIZE"]
              if k in os.environ
          }
      )
      if "RELEASE_BUILD" not in environment:
          environment["RELEASE_BUILD"] = "false"
  
      tag = get_docker_tag(platform=platform, registry=docker_registry)
      mx_root = get_mxnet_root()
      local_build_folder = buildir()
      # We need to create it first, otherwise it will be created by the docker daemon with root only permissions
      os.makedirs(local_build_folder, exist_ok=True)
      os.makedirs(local_ccache_dir, exist_ok=True)
      logging.info("Using ccache directory: %s", local_ccache_dir)
  
      # Log enviroment
      logging.info("environment ---> {0}".format(environment))
  
      # Build docker command
      docker_arg_list = [
          "--cap-add",
          "SYS_PTRACE",  # Required by ASAN
          "--rm",
          "--shm-size={}".format(shared_memory_size),
          # mount mxnet root
          "-v",
          "{}:/work/mxnet".format(mx_root),
          # mount mxnet/build for storing build
          "-v",
          "{}:/work/build".format(local_build_folder),
          "-v",
          "{}:/work/ccache".format(local_ccache_dir),
          "-u",
          "{}:{}".format(os.getuid(), os.getgid()),
          "-e",
          "CCACHE_MAXSIZE={}".format(environment["CCACHE_MAXSIZE"]),
          # temp dir should be local and not shared
          "-e",
          "CCACHE_TEMPDIR={}".format(environment["CCACHE_TEMPDIR"]),
          # this path is inside the container as /work/ccache is mounted
          "-e",
          "CCACHE_DIR={}".format(environment["CCACHE_DIR"]),
          # a container-scoped log, useful for ccache verification.
          "-e",
          "CCACHE_LOGFILE={}".format(environment["CCACHE_LOGFILE"]),
          # whether this is a release build or not
          "-e",
          "RELEASE_BUILD={}".format(environment["RELEASE_BUILD"]),
      ]
      docker_arg_list += [tag]
      docker_arg_list.extend(command)
  
      def docker_run_cmd(cmd):
          logging.info("Running %s in container %s", command, tag)
          logging.info("Executing command:\n%s\n", " \\\n\t".join(cmd))
          subprocess.run(
              cmd, stdout=sys.stdout, stderr=sys.stderr, check=True
          )
  
      if not dry_run:
          if not nvidia_runtime:
              docker_run_cmd(["docker", "run"] + docker_arg_list)
          else:
              try:
                  docker_run_cmd(
                      ["docker", "run", "--gpus", "all"]
                      + docker_arg_list
                  )
              except subprocess.CalledProcessError as e:
                  if e.returncode == 125:
                      docker_run_cmd(
                          ["docker", "run", "--runtime", "nvidia"]
                          + docker_arg_list
                      )
                  else:
                      raise
  
      return 0
  
file_path: mxnet/ci/build.py
imports: import argparse
  import pprint
  import os
  import signal
  import subprocess
  from itertools import chain
  from subprocess import check_call
  from typing import *
  import yaml
  from util import *
label_desc: Use image node_id 6 for calling a global function with example usage: container_run(platform, nvidia_runtime, docker_registry, shared_memory_size, local_ccache_dir, command, environment, dry_run) and returns: int