2016-10-04 87 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