[root@Tseng-HW system]# docker exec -it jenkins bash
jenkins@235130a2d962:/$ 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
root@235130a2d962:/# cd /var/run/
root@235130a2d962:/var/run# ls -l
total 4
srw-rw---- 1 root 990 0 Jun 25 06:02 docker.sock
drwxrwxrwt 2 root root 4096 Dec 20 2021 lock
-rw-rw-r-- 1 root utmp 0 Dec 20 2021 utmp
root@235130a2d962:/var/run# cat /etc/group | grep docker
docker:x:998:jenkins
-- 删除错误的用户组
root@235130a2d962:/var/run# groupdel docker
-- 查看某用户组是否存在
root@235130a2d962:/var/run# cat /etc/group | grep docker
-- 创建用户组
root@235130a2d962:/var/run# groupadd -g 990 docker
-- 添加用户到用户组
root@235130a2d962:/var/run# usermod -aG docker jenkins
root@235130a2d962:/var/run# exit
exit
[root@Tseng-HW system]# docker exec -it jenkins bash
jenkins@235130a2d962:/$ cd /var/run/
jenkins@235130a2d962:/var/run$ ls -l
total 4
srw-rw---- 1 root docker 0 Jun 25 06:02 docker.sock
drwxrwxrwt 2 root root 4096 Dec 20 2021 lock
-rw-rw-r-- 1 root utmp 0 Dec 20 2021 utmp
jenkins@235130a2d962:/var/run$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
235130a2d962 jenkins/jenkins "/sbin/tini -- /usr/…" 22 hours ago Up 57 minutes 0.0.0.0:50000->50000/tcp, :::50000->50000/tcp, 0.0.0.0:1581->8080/tcp, :::1581->8080/tcp jenkins
jenkins@235130a2d962:/var/run$ exit
exit
[root@Tseng-HW system]# docker restart 2351
2351
[root@Tseng-HW system]#