2016-10-04 58 views
0

为了监视我的搬运工容器,我决定通过以下规则通过nginx的暴露搬运工远程API:允许nginx的阅读docker.sock

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组运行。

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

回答

0

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?

对于这个问题,你可以在其下运行dockernginx添加user

-H <ip address>:2375 

您可以在输出配置文件的位置:

usermod -a -G www-data,docker user 
0

您可以通过在守护程序配置文件中添加下列文本到ExecStart打开守护进程的HTTP套接字命令:

systemctl status docker