Docker as root?

Are all docker commands meant to run as root?

$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied

However $ sudo docker ps works

In case anyone else wants to know too:

# install docker
sudo swupd bundle-add containers-basic 

# launch docker without reboot
sudo systemctl enable --now docker

# add current user to docker group to allow docker commands without root
sudo usermod -aG docker $USER

# make permission change above take effect without restarting
exec su -l $USER
1 Like