What is the difference between $container->get('current_user') and global $user?
The general idea is to not use service location but define the dependencies directly in the container. There are edge cases where you need to pass along the full container, but really, try to avoid them. For objects like plugins and controllers we use a static factory pattern, on which you get the container to get your dependencies. Note: There aren't any objects which depend on those.

On top of that you also should avoid having to change services. As much as possible! Instead you should build a wrapper service which has a method like the \Drupal\Core\Session\AccountProxy ... you can set the current user on there
using setAccount.

  public function __construct(AccountInterface $current_user) {
    $this-&gt;currentUser = $current_user;
  }

  public function doSomething() {
    $this-&gt;currentUser-&gt;setAccount(new UserSession(...));
  }