简体   繁体   English

docker-compose:尝试“上载”容器时不使用枪杀

[英]docker-compose: no gunicorn when trying “up” container

I'm facing with issue when I try to "up" my container on DigitalOcean env. 当我尝试在DigitalOcean env上“上载”我的容器时,我遇到了问题。 I have Ubuntu Docker 1.7.1 on 14.04 as env droplet. 在14.04上Ubuntu Docker 1.7.1作为env Drop。 There is the next error. 下一个错误。

mysite | ./docker-entrypoint: line 8: exec: gunicorn: not found

This is my Dockerfile where I tried to add gunicorn setup by (apt-get, pip). 这是我的Dockerfile,我尝试通过(apt-get,pip)添加gunicorn设置。 Sadly but it doesn't work I have the same issue with missed gunicorn module. 可悲的是,但是它不起作用,我错过了gunicorn模块的问题。

Dockerfile Docker文件

FROM python:2.7.7

RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get -y install nodejs
RUN apt-get -y install libpango1.0-0 libgdk-pixbuf2.0-0

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . /usr/src/app

VOLUME /usr/src/app/venv
VOLUME /usr/src/app/node_modules
VOLUME /usr/src/app/static

ENTRYPOINT ["./docker-entrypoint"]

Additionally I tried to add gunicorn setup to the entry point file which also didn't work there is "no gunicorn module" error still. 另外,我尝试将gunicorn设置添加到入口点文件,该文件也无法正常工作,仍然存在“ no gunicorn module”错误。 I guess it wasn't a great idea to add it here but anyway I've checked. 我想在这里添加它不是一个好主意,但是无论如何我都检查过。

Docker entry point Docker入口点

#!/bin/bash
set -e

if [[ -e venv/bin/activate ]]; then
    source venv/bin/activate
fi

exec "$@"

docker-compose.yml docker-compose.yml

source:
  extends:
    file: docker-compose-common.yml
    service: prod
  build: .
  command: bin/install

redis:
  image: redis:latest
  command: redis-server --appendonly yes

mysite:
  extends:
    file: docker-compose-common.yml
    service: prod
  image: mysitecatalogweb_source
  volumes_from:
    - source
  environment:
    - SITE_ID=1
  command: gunicorn -k gevent -b 0.0.0.0:8000 --access-logfile - --error-logfile - mysite.wsgi

docker-compose-common.yml docker-compose-common.yml

dev:
  environment:
    - PYTHONUNBUFFERED=1
    - ENV=DEV
    - POSTGRES_HOST=host
    - POSTGRES_USER=user
  env_file: dev.env

prod:
  environment:
    - ENV=PROD
  env_file: prod.env

Maybe I need to add gunicorn setup to the bin/install directly (which should be called from source task) but this is also can be found in the requirements.txt EDITED: I've tried to add gunicorn here and it is still mysite | ./docker-entrypoint: line 8: exec: gunicorn: not found 也许我需要直接将gunicorn安装程序添加到bin / install中(应该从任务中调用),但这也可以在requirements.txt中找到。 编辑:我试图在此处添加gunicorn,但仍然是mysite | ./docker-entrypoint: line 8: exec: gunicorn: not found mysite | ./docker-entrypoint: line 8: exec: gunicorn: not found

bin/install 装箱/安装

set -e

pip install virtualenv
if [[ ! -e venv/bin/activate ]]; then
  virtualenv venv
  source venv/bin/activate
fi

pip install -r requirements.txt

mkdir -p static/js
npm install
npm run browserify

Also check my requirements.txt https://gist.github.com/alexnodejs/3789b4eb7621687e010b 还要检查我的需求.txt https://gist.github.com/alexnodejs/3789b4eb7621687e010b

Maybe someone already bumped with similar issue with unicorn? 也许有人已经为独角兽遇到了类似的问题? Please advise where I should dig. 请告知我应该在哪里挖。

The main problem I see is that you're using image: mysitecatalogweb_source for your mysite service, and expecting that to include the committed result of running bin/install , which wasn't actually committed to the mysitecatalogweb_source image -- it's sitting in a container instead, so the virtualenv was never created in the second mysite container, and is thus not activated and gunicorn is not available. 我认为主要的问题是,你正在使用image: mysitecatalogweb_source为您mysite服务,并期望对包括运行的承诺结果bin/install ,这本来就不是致力于mysitecatalogweb_source图像-这是坐在容器相反,因此virtualenv从未在第二个mysite容器中创建,因此无法激活, gunicorn无法使用gunicorn From just the snippet here, it appears that you ought to add RUN bin/install to your Dockerfile so that the virtualenv is set up before the attempt to use it. 仅从这里的片段看来,您应该将RUN bin/install添加到Dockerfile以便在尝试使用virtualenv之前对其进行设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM