Run the Docker daemon as a non-root user

To create the docker group and add your user:

  1. Create the docker group.

    sudo groupadd docker
  2. Add your user to the docker group.

    sudo usermod -aG docker $USER
  3. Log out and log back in so that your group membership is re-evaluated.

    If you're running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.

  4. You can also run the following command to activate the changes to groups:

    newgrp docker
  5. Verify that you can run docker commands without sudo.

    docker run hello-world