Docker:uwsgi没有开始

时间:2017-05-17 06:41:24

标签: python-2.7 docker dockerfile uwsgi

当我从docker容器内部启动uwsgi时,一切正常。 我打电话给:

docker run -it -p 9098:9098 --rm --entrypoint=/bin/bash pyramid:latest

在容器内我打电话:

jenkins@9c36ddb99971:~/my_project$ uwsgi --ini-paste dev.ini --chdir /home/jenkins/my_project/
[uWSGI] getting INI configuration from dev.ini
jenkins@9c36ddb99971:~/my_project

一切都正常运行。

docker ps -a
9c36ddb99971        pyramid:latest      "/bin/bash"              About a minute ago   Up About a minute           0.0.0.0:9098->9098/tcp   festive_ride

当我尝试从外部启动uwsgi服务时,uwsgi没有运行

me@me-W35 ~/docker_test/pyramid $ docker run -it -p 9098:9098 --rm pyramid:latest
[uWSGI] getting INI configuration from /home/jenkins/my_project/dev.ini
me@me-W35 ~/docker_test/pyramid

我尝试了ENTRYPOINT,CMD,RUN ......没有用。什么都没发生。没有错误。

这是我的Dockerfile:

FROM ubuntu:16.04

RUN apt-get update -y && \
    apt-get install -y python-pip python-dev && \
    apt-get install -y curl && \
    apt-get install -y wget && \
    apt-get install -y zlib1g-dev && \
    apt-get install -y libssl-dev && \
    apt-get install -y libffi-dev && \
    apt-get install -y vim && \
    apt-get install -y iputils-ping && \
    pip install --upgrade pip setuptools && \
    apt-get install -y git && \
    apt-get install -y libpq-dev && \
    apt-get install -y libxml2-dev && \
    apt-get install -y libxmlsec1-dev && \
    apt-get install -y libsqlite3-dev

RUN useradd -m jenkins
USER jenkins
ENV HOME /home/jenkins

# Install Python 2.7.11
RUN curl -o $HOME/Python-2.7.11.tar.xz  https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz && \
    tar -xf $HOME/Python-2.7.11.tar.xz -C $HOME && \
    cd $HOME/Python-2.7.11 && ./configure --prefix=$HOME/local/python2711 && make && make install

COPY requirements.txt $HOME/

USER jenkins

# Install pip
RUN curl -s https://bootstrap.pypa.io/get-pip.py > /tmp/get-pip.py && \
    $HOME/local/python2711/bin/python2.7 /tmp/get-pip.py && \
    $HOME/local/python2711/bin/pip install virtualenv

RUN $HOME/local/python2711/bin/virtualenv $HOME/my_project
WORKDIR $HOME/my_project
RUN . $HOME/my_project/bin/activate;

RUN $HOME/local/python2711/bin/pip install -r $HOME/requirements.txt

ENV PATH $HOME/local/python2711/bin:$PATH
ENV PYTHONPATH $HOME/local/python2711/lib

COPY dev.ini $HOME/my_project/
USER root
RUN chown -R jenkins:jenkins $HOME/
USER jenkins

EXPOSE 9098
CMD ["uwsgi", "--ini-paste", "/home/jenkins/my_project/dev.ini", "--chdir", "/home/jenkins/my_project"]

dev.ini:

###

# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/environment.html
###

[app:main]
use = egg:my_package

pyramid.reload_templates = false
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/logging.html
###

[loggers]
keys = root, my_package

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console

[logger_my_package]
level = WARN
handlers =
qualname = my_package

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 9099

[uwsgi]
http = 0.0.0.0:9098
socket = :9097
master = true
module = my_package:application
processes = 4
harakiri = 3600
harakiri-verbose = true
limit-post = 65536
post-buffering = 8192
#logto = /home/jenkins/my_package.log
daemonize = /home/jenkins/my_package.log
pidfile = /home/jenkins/my_package.pid
stats = /home/jenkins/my_packagestats
listen = 128
max-requests = 1000
reload-on-as = 128
reload-on-rss = 96
no-orphans = true
log-slow = true
need-app = true
memory-report = true

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。在dev.ini中,我必须改变这样的“取消注释”:

pick.col = function(color) {

plot(1, pch = 19, cex = 8 , col = color)

}

pick.col(color = "yellow")

在Dockerfile中:

logto = /home/jenkins/my_package.log
#daemonize = /home/jenkins/my_package.log

现在uwsgi正确启动。