docs: def inspect_to_container_metadata(c_metadata_object, inspect_data, image_instance):
      """
      process data from `docker container inspect` and update provided container metadata object
  
      :param c_metadata_object: instance of ContainerMetadata
      :param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()`
      :param image_instance: instance of DockerImage
      :return: instance of ContainerMetadata
      """
      inspect_to_metadata(c_metadata_object, inspect_data)
  
      status = ContainerStatus.get_from_docker(
          graceful_get(inspect_data, "State", "Status"),
          graceful_get(inspect_data, "State", "ExitCode"),
      )
  
      image_id = graceful_get(inspect_data, "Image")
      if image_id:
          if ":" in image_id:
              # format of image name from docker inspect:
              # sha256:8f0e66c924c0c169352de487a3c2463d82da24e9442fc097dddaa5f800df7129
              image_instance.identifier = image_id.split(':')[1]
          else:
              # container
              image_instance.identifier = image_id
  
      # format of Port mappings from docker inspect:
      # {'12345/tcp': [
      #   {'HostIp': '0.0.0.0', 'HostPort': '123'},
      #   {'HostIp': '0.0.0.0', 'HostPort': '1234'}]}
      port_mappings = dict()
  
      raw_port_mappings = graceful_get(inspect_data, 'HostConfig', 'PortBindings') or {}
  
      for key, value in raw_port_mappings.items():
          for item in value:
              logger.debug("parsing ports: key = %s, item = %s", key, item)
              li = port_mappings.get(key, [])
              raw_host_port = item['HostPort']
              if raw_host_port == "":
                  int_port = None
              else:
                  try:
                      int_port = int(raw_host_port)
                  except ValueError as ex:
                      logger.error("could not parse port: %s", ex)
                      continue
              li.append(int_port)
              port_mappings.update({key: li})
  
      c_metadata_object.status = status
      c_metadata_object.port_mappings = port_mappings
      c_metadata_object.hostname = graceful_get(inspect_data, 'Config', 'Hostname')
      raw_networks = graceful_get(inspect_data, "NetworkSettings", "Networks").values()
      if raw_networks:
          c_metadata_object.ipv4_addresses = [
              graceful_get(x, "IPAddress")
              for x in raw_networks if graceful_get(x, "IPAddress")]
          c_metadata_object.ipv6_addresses = [
              graceful_get(x, "GlobalIPv6Address")
              for x in raw_networks if graceful_get(x, "GlobalIPv6Address")]
      c_metadata_object.image = image_instance
      name = graceful_get(inspect_data, "Name")
      if name:
          name = name[1:] if name.startswith("/") else name  # remove / at the beginning
          c_metadata_object.name = name
  
      return c_metadata_object