You need to add your current user to docker group like following:
sudo usermod -aG docker <your username>
Also, you can use USER environment variable like:
sudo usermod -aG docker $USER
Then restart the system. As the docker documentation says:
The docker daemon binds to a Unix socket instead of a TCP port. By default that
Unix socket is owned by the user root and other users can access it
withsudo. For this reason, docker daemon always runs as the root
user.To avoid having to use
sudowhen you use thedockercommand, create a
Unix group calleddockerand add users to it. When the docker daemon
starts, it makes the ownership of the Unix socket read/writable by the
dockergroup.