title: Non-interactive bash script re logging after `usermod -aG`
body: <p>There are commands that require users to be in a group to execute.
  I am running a non-interactive bash script <code>script.sh</code> like below</p>
  <pre class="lang-bash prettyprint-override"><code>#!/bin/bash
  
  sudo usermod -aG $USER docker
  
  # this line requires user logging to succeed
  docker ps
  </code></pre>
  <p>When invoking the script for the first time <code>bash script.sh</code>, the line <code>docker ps</code> will complain insufficient permission since the new group membership modified by line <code>sudo usermod -aG $USER docker</code> requires the user to re-log into the shell to take effect.</p>
  <p>My question: is there a way I can trigger the re-log in an non-interactive way?</p>