gpt4 book ai didi

nginx - 允许Nginx读取docker.sock

转载 作者:行者123 更新时间:2023-12-02 20:19:29 26 4
gpt4 key购买 nike

为了监视我的Docker容器,我决定通过nginx通过以下规则公开docker远程API:

server {
listen 1234;
server_name xxx.xxx.xxx.xxx;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unix:/var/run/docker.sock;
}
}

但是在 nginx.error文件中,出现以下错误:
connect() to unix:/var/run/docker.sock failed (13: Permission denied

原因是docker.sock是 docker组的所有者,而nginx在 www-data组中运行。

解决此问题的最佳方法是什么?

最佳答案

The reason is that docker.sock is under the ownership of docker group while nginx is running in www-data group.

What is the best way to solve this problem?



对于此问题,您可以将正在运行 usernginx添加到 docker组。
usermod -a -G www-data,docker user

关于nginx - 允许Nginx读取docker.sock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39848796/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com