How can I inject container to a class with constructor having arguments? Fatal error: Declaration of Drupal\migrate_upgrade\MigrateUpgradeDrushRunner::create(Psr\Container\ContainerInterface $container, $options = Array) must be compatible with Drupal\Core\DependencyInjection\ContainerInjectionInterface::create(Symfony\Component\DependencyInjection\ContainerInterface $container)


Below is MigrateUpgradeCommands.php file
where I am creating an instance of new MigrateUpgradeDrushRunner() and passing two arguments $options and $this-&gt;logger

    class MigrateUpgradeCommands extends DrushCommands {
    /**
       * Logger service.
       *
       * @var \Drupal\Core\Logger\LoggerChannelInterface
       */
      protected $logger;

      /**
       * MigrateUpgradeCommands constructor.
       *
       * @param \Drupal\Core\State\StateInterface $state
       *   State service.
       * @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerChannelFactoryInterface
       *   The logger.factory service.
       */
      public function __construct(StateInterface $state, LoggerChannelFactoryInterface $loggerFactory) {
        $this-&gt;state = $state;
        $this-&gt;logger = $loggerFactory-&gt;get('drush');
      }
/**
   * Perform one or more upgrade processes.
   *
   * @command migrate:upgrade
   *
   * @usage drush migrate-upgrade --legacy-db-url='mysql://root:pass@127.0.0.1/d6'
   *   Upgrade a Drupal 6 database to Drupal 8
   * @usage drush migrate-upgrade --legacy-db-key='drupal_7'
   *   Upgrade Drupal 7 database where the connection to Drupal 7 has already
   * been created in settings.php ($databases['drupal_7'])
   * @usage drush migrate-upgrade --legacy-db-url='mysql://root:pass@127.0.0.1/d7' --configure-only --migration-prefix=d7_custom_ --legacy-root=https://www.example.com
   *   Generate migrations for a custom migration from Drupal 7 to Drupal 8
   *
   * @validate-module-enabled migrate_upgrade
   *
   * @aliases migrate-upgrade, mup
   *
   * @throws \Exception
   *   When an error occurs.
   */
  public function upgrade(array $options = []) {
    $runner = new MigrateUpgradeDrushRunner($options, $this-&gt;logger);

    $runner-&gt;configure();
    if ($options['configure-only']) {
      $runner-&gt;export();
    }
    else {
      $runner-&gt;import();
      $this-&gt;state-&gt;set('migrate_drupal_ui.performed', \Drupal::time()-&gt;getRequestTime());
    }
    // Remove the global database state.
    $this-&gt;state-&gt;delete('migrate.fallback_state_key');
  }

    }


Now file MigrateUpgradeDrushRunner.php

class MigrateUpgradeDrushRunner implements ContainerInjectionInterface {
  /**
   * Logger channel.
   *
   * @var \Drupal\Core\Logger\LoggerChannelInterface
   */
  protected $logger;

  public static function create(ContainerInterface $container, $options = []) {
    return new static(
      $container-&gt;get('logger.factory'),
      $options
    );
  }

  /**
   * MigrateUpgradeDrushRunner constructor.
   *
   * @param array $options
   *   Drush options parameters.
   * @param \Drupal\Core\Logger\LoggerChannelInterface $logger
   *   Drush logger.
   */
  public function __construct(array $options = [], LoggerChannelInterface $logger) {
    $this-&gt;setOptions($options);
    $this-&gt;logger = $logger;
  }


}


Basically, how can I inject Container into MigrateUpgradeDrushRunner so that I can fetch logger.factory service and pass it in the construct ?
Instead of adding $options to your create method you shall add a method to set the options.

Take a look at this code to see how you can inject $logger in your class:

class MigrateUpgradeDrushRunner implements ContainerInjectionInterface {

  /**
   * The logger channel factory.
   * 
   * @var LoggerChannelFactoryInterface 
   */
  protected $logger;

  /**
   * The options.
   * 
   * @var array
   */
  protected $options = [];

  /**
   * MigrateUpgradeDrushRunner constructor.
   * 
   * @param LoggerChannelFactoryInterface $logger
   *   The logger channel factory.
   */
  public function __construct(LoggerChannelFactoryInterface $logger) {
    $this-&gt;logger = $logger;
  }

  /**
   * {@inheritDoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container-&gt;get('logger.factory')
    );
  }


  /**
   * Set the options.
   *
   * @params array $options
   *   The options.
   */
  public function setOptions(array $options) {
    // Do something...
  }

}