code: def get_first_host_port(self):
          
          mapped_ports = {p: m for p, m in self.ports.items() if m is not None}
          if not mapped_ports:
              raise RuntimeError('Container has no published ports')
  
          def sort_key(port_string):
              port, proto = port_string.split('/', 1)
              return int(port), proto
          firt_port_spec = sorted(mapped_ports.keys(), key=sort_key)[0]
  
          return self._host_port(firt_port_spec, 0)
docs: Get the first mapping of the first (lowest) container port that has a
          mapping. Useful when a container publishes only one port.
  
          Note that unlike the Docker API, which sorts ports lexicographically
          (e.g. ``90/tcp`` > ``8000/tcp``), we sort ports numerically so that the
          lowest port is always chosen.