Linux non-root users use Docker usually when we use the Linux system, it is best not to use the root account directly, but when using Docker, the default is not the use of non-root users, for reasons, the official statement is as follows:
The Docker daemon binds to a Unix socket instead of a TCP port. By default, Unix socket is owned by the user root and other users can access it with sudo. For this reason, Docker Daemon always runs as the root user.
To avoid has the use of sudo when your use of the Docker command, create a Unix group called Docker and add users to it. When the Docker daemon starts, it makes the ownership of the Unix sockets read/writable by the Docker group.
Here are the steps to make root available to non-root users: 1
创建docker组sudo groupadd docker
2
将当前用户加入docker组sudo gpasswd -a ${USER} docker
3
重新启动docker服务(下面是CentOS7的命令)sudo systemctl restart docker
4
当前用户退出系统重新登陆
5
运行docker命令,测试docker ps
Reference: http://blog.csdn.net/kongxx/article/details/52413332
Non-root users using Docker under Linux