Table of Contents

Docker - Allow docker to be run without using sudo

Add current user to the docker group

sudo usermod -aG docker $USER

NOTE: This allows docker to be run without using sudo.

To enable this functionality, log out and log back in; or run:

newgrp docker

Add a specific user to the docker group

Determine the username

whoami

returns:

peter

Add this user to the docker group

sudo usermod -aG docker peter

NOTE: Any user can be added to the docker group as required.


Enable this functionality

Either log out and log back in; or run:

newgrp docker

Verify that docker commands can be run without sudo

docker run hello-world

NOTE: If an error is seen such as docker: Got permission denied while trying to connect to the Docker daemon socket, then:

sudo chmod 666 /var/run/docker.sock