普通用户使用docker命令

一、授权普通用户直接使用docker命令

1、将 test帐号加入到docker组

[root@host-client ~]# useradd test

[root@host-client ~]# passwd test

[root@host-client ~]# gpasswd -a test docker

[root@host-client ~]# groups test #确认zabbix所属组

test : test docker

2、授权免密使用sudo权限

[root@host-client ~]# chmod 755 /etc/sudoers

[root@host-client ~]# vim /etc/sudoers

test ALL=(ALL)       NOPASSWD: ALL

3、切换test帐号验证

[root@host-client ~]# su - test

[root@host-client ~]# docker ps -a --format "{{.Names}}"

portainer

owncloud_server

owncloud_mariadb

二、授权普通用户通过sudo使用docker命令

1、授权免密使用sudo权限

[root@host-client ~]# chmod 755 /etc/sudoers

[root@host-client ~]# vim /etc/sudoers

test  ALL=(ALL)       NOPASSWD:/usr/bin/grep,/usr/bin/docker

2、切换test帐号验证

[root@host-client ~]# su - test

[root@host-client ~]# sudo docker ps -a --format "{{.Names}}"

portainer

owncloud_server

owncloud_mariadb

你可能感兴趣的:(linux运维,docker,eureka,容器)