code: def get_port_mappings(self, port=None):
          
          port_mappings = self.inspect(refresh=True)["NetworkSettings"]["Ports"]
  
          if not port:
              return port_mappings
  
          if str(port) not in self.get_ports():
              return []
  
          for p in port_mappings:
              if p.split("/")[0] == str(port):
                  return port_mappings[p]
docs: Get list of port mappings between container and host. The format of dicts is:
  
              {"HostIp": XX, "HostPort": YY};
  
          When port is None - return all port mappings. The container needs
          to be running, otherwise this returns an empty list.
  
          :param port: int or None, container port
          :return: list of dict or None; dict when port=None