by Radosław Śmigielski
On some linux distros Docker daemon runs as root:root which is not always what you want on your dev machine.
On real production system you probably want to leave docker running under root acount because docker group grants privileges almost equivalent to the root user. More on that topic Docker Daemon Attack Surface
Below you can find how to run docker under different than root group and let you add normal users to docker group and not to use root account to work with docker.
sudo groupadd docker
sudo usermod -aG docker $USER
cp /usr/lib/systemd/system/docker.service /etc/systemd/system/docker.service
-G, --group=""
Group to assign the unix socket specified by -H when running in daemon mode.
use '' (the empty string) to disable setting of a group. Default is docker.
Edit your custom docker service file /etc/systemd/system/docker.service and in section ExecStart add –group option
ExecStart=/usr/bin/dockerd-current \
...
--group docker \
...
systemctl daemon-reload
systemd-delta --type=overridden
systemctl restart docker.service
$ ls -al /var/run/docker.sock
srw-rw----. 1 root docker 0 Sep 10 04:59 /var/run/docker.sock