在Docker中运行的uwsgi可以找到初始化文件

时间:2015-03-17 16:23:19

标签: python linux docker ubuntu-14.04 uwsgi

我使用Ubuntu 14.04和Docker 1.0.1。我有一个包含python 2.7.6和uwsgi 2.0.10的容器。我创建了Dockerfile:

FROM romeus/python 
MAINTAINER Me <my email>
ENV REFRESHED_AT 2015-03-17

RUN pip install uwsgi
RUN pip install Django 

RUN mkdir -p /var/www
RUN mkdir -p /var/conf 

VOLUME ["/var/www"]
ADD uwsgi.conf /var/conf/


CMD ["uwsgi", "--ini", "/var/conf/uswgi.conf"]

下面我放置了uswgi.conf:

[uwsgi]
http-socket = 0.0.0.0:8080
wsgi-file = /var/www/test.py 
processes = 4
threads = 2
stats = 0.0.0.0:8081

当我登录容器时:

docker run --rm -it -p 8080 -p 8081 -v /home/hedin/projects/business
/project/test/www:/var/www/ romeus/django /bin/bash

然后使用ini-file运行uwsgi:

uwsgi --ini /var/conf/uwsgi.conf

它开始并按预期工作。

但是当我运行它时:

docker run --rm -it -p 8080 -p 8081 -v /home/hedin/projects/business/project/test/www:/var/www/ romeus/django

它发出错误: /var/conf/uswgi.conf的realpath()失败:没有这样的文件或目录[core / utils.c line 360​​7]

有人知道什么是问题吗?

P.S。我更改了Dockerfile的尾部:

COPY uwsgi.conf /var/conf/

VOLUME ["/var/www"]

CMD ["strace", "-f", "uwsgi", "--ini", "/var/conf/uswgi.conf"]

这是strace输出的最后几行:

lstat("/var/conf/uswgi.conf", 0x7fff9dcc6a40) = -1 ENOENT (No such file   or directory)
lstat("/var", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/conf", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/var/conf/uswgi.conf", 0x7fff9dcc59e0) = -1 ENOENT (No such file or directory)
write(2, "realpath() of /var/conf/uswgi.co"..., 94realpath() of /var/conf/uswgi.conf failed: No such file or directory [core/utils.c line 3607]
) = 94
exit_group(1)                           = ?
+++ exited with 1 +++

所以看起来文件在命令运行时不存在。 有什么想法吗?

1 个答案:

答案 0 :(得分:5)

我犯了一个愚蠢的错误。文件名必须是'uwsgi.conf',而不是'uwsgi.conf'。当我修复它时,所有都按预期开始工作。