Docker permission issue after install
1. Permission denied after installing Docker
If a permission denied error occurs when you check docker ps after docker installation is complete, add the user to the docker group.
sudo usermod -aG docker ${USER}
If you reconnect with the account, you can use docker without a permission denied error.
user1@my-server:~$ docker -v
Docker version 20.10.22, build 3a2c30b
user1@my-server:~$ 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.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied
user1@my-server:~$ sudo usermod -aG docker user1
user1@my-server:~# cat /etc/group | grep docker
docker:x:136:user1
user1@my-server:~$docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
If the above command does not solve the problem, grant permission to /var/run/docker.sock.
chmod 666 /var/run/docker.sock
ser1@my-server:~$ 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.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied
user1@my-server:~$ sudo chmod 666 /var/run/docker.sock
user1@my-server:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES