Permission for -v /var/run/docker.sock

If you only set the uid, the user still belongs to the root group:

docker run  -u $(id -u) -it -v /var/run/docker.sock:/var/run/docker.sock alpine id
uid=1001 gid=0(root) groups=0(root)

Thus, if instead of 755, your permissions would be 660, it should work. You do not want to give others access to the docker sock, as it would mean everyone could create containers that could be used for privilege escalation.


Note: By default the permissions and ownership for the docker.sock should look like this:

srw-rw---- 1 root docker 0 xxx  x xx:xx /var/run/docker.sock

Your docker.sock looks modified and lacks write permissions for the group.

You can either add the group id to the -u argument, or use --group-add to add it as additional group. To illustrate the outcome, I used alpine as image and id as command to see the effect:

docker run  -u $(id -u):$(getent group docker | cut -d: -f3) -it -v /var/run/docker.sock:/var/run/docker.sock alpine id
uid=1001 gid=999(ping) groups=999(ping)
docker run  -u $(id -u) --group-add $(getent group docker | cut -d: -f3) -it -v /var/run/docker.sock:/var/run/docker.sock alpine id
uid=1001 gid=0(root) groups=0(root),999(ping)