You can get the hostname, "drupal8.local", directly from the getHost() request:
$host = \Drupal::request()->getHost(); In some cases you might want to get the schema as well, fx https://drupal8.local:
$host = \Drupal::request()->getSchemeAndHttpHost();