【发布时间】:2017-08-18 02:02:29
【问题描述】:
在我的 Mac 上,我在 VMware 中运行 Windows Server 2016。在那里,我在 vagrant/Virtual Box 中运行 Ubuntu。在那里,我试图在带有 nginx/uwsgi 的 docker 容器中运行 django 应用程序。
uwsgi 无法以以下方式开始:
[uWSGI] getting INI configuration from /opt/django/CAPgraph/uwsgi.ini
*** Starting uWSGI 2.0.15 (64bit) on [Thu Aug 17 20:01:23 2017] ***
compiled with version: 6.4.0 20170805 on 17 August 2017 06:10:50
os: Linux-3.13.0-128-generic #177-Ubuntu SMP Tue Aug 8 11:40:23 UTC 2017
nodename: 37db4344b5ae
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/local/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to /opt/django/CAPgraph/
your memory page size is 4096 bytes
detected max file descriptor number: 524288
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
bind(): Operation not permitted [core/socket.c line 230]
在 VMware 中,该文件夹设置为供具有写入权限的所有人共享。它安装在 777 的 vagrant VM 中,在 docker 容器中也是 777。我可以从所有 3 个位置在 dir 中创建文件。但似乎 uwsgi 无法创建套接字。
我尝试了一个简短的 python 脚本作为 vagrant 的测试,但也无法创建套接字:
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/vagrant/app.sock')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 1] Operation not permitted
有谁知道我该如何解决这个问题?
更新:我将目录更改为 /tmp,我可以在其中使用我的 python 脚本创建一个套接字,但 uwsgi 仍然失败并出现相同的错误。
更新 2:我使用我的 python 脚本在 /tmp 中创建了套接字,将其 chmod 编辑为 777,但我仍然从 uwsgi 收到相同的错误。
【问题讨论】:
-
问题是
/vagrant和普通文件夹不一样。如果执行命令mount | grep vagrant,你会发现它使用vboxfs文件系统,它不能很好地与docker 结合 -
关于如何解决这个问题的任何建议?
-
使用
/vagrant以外的任何其他文件夹。我通常使用/home/vagrant -
谢谢 - 成功了!
-
我说得太早了。正在创建套接字,但是当我尝试连接到该站点时,它失败并出现此 nginx 错误:
2017/08/19 16:56:29 [crit] 1251#1251: *1 connect() to unix:///opt/django/CAPgraph/app.sock failed (13: Permission denied) while connecting to upstream, client: 10.0.2.2, server: , request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///opt/django/CAPgraph/app.sock:", host: "localhost:9003"我已验证 app.sock 文件和路径上的所有目录都是 777。
标签: docker nginx vagrant vmware uwsgi