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 only access it using sudo. The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

引用自官方文档

问题说明

普通用户在使用docker时候报错,提示权限不足,导致docker功能无法正常使用,此文章将解决该问题

解决步骤

  1. 创建 docker 用户组( 一般安装docker已经存在 )

sudo groupadd docker

  1. 添加当前用户( 如果想要添加其他用户修改 $USER 位置为对应的用户名就好 )到 docekr

sudo usermod -aG docker $USER

  1. 重启系统后普通用户即可使用 docker ,如果不想重启直接使用,可以使用以下命令

newgrp docker

  1. 再次执行 docker info 命令进行验证