Your user is not in the docker group
CommonA fresh Docker Engine install on Linux lets only root and the docker group use the socket. Until someone adds your user to the group, every docker command without sudo is refused.
Confirm
ls -l /var/run/docker.sock && getent group docker
Group docker on the socket, and your user name missing from the getent line
Fix
- Decide whether this user should have root-level control of the host. If not, use rootless mode instead.
- Add the user to the group, then start a new login session: log out and back in, or reboot a virtual machine.
newgrp dockerapplies it to one new shell straight away. - Check with
docker run hello-world, without sudo.
sudo groupadd docker sudo usermod -aG docker $USER newgrp docker docker run hello-world
From Docker's Linux post-install steps. groupadd reports that the group already exists if the install created it, which is harmless. -a appends; without it usermod replaces your other groups.