使用docker-compose在基于ubuntu的图像上运行gunicorn

时间:2016-10-24 12:37:16

标签: python ubuntu docker docker-compose dockerfile

我有使用ubuntu作为基本图像的图像,它使用我的烧瓶应用程序运行gunicorn并且它在使用docker时运行正常。这是我的形象。

FROM ubuntu:trusty

RUN apt-get update

RUN apt-get install -yqq python2.7 python-pip python-dev wget vim gunicorn python-virtualenv supervisor
RUN pip install gunicorn

#KONFIGURACJA QGIS 
RUN echo "deb http://qgis.org/debian-ltr trusty main" >> /etc/apt/sources.list
RUN echo "deb-src http://qgis.org/debian-ltr trusty main" >> /etc/apt/sources.list
RUN wget -O - http://qgis.org/downloads/qgis-2016.gpg.key | gpg --import && gpg --fingerprint 073D307A618E5811 && gpg --export --armor 073D307A618E5811 | apt-key add -
RUN apt-get update && apt-get install -yqq \
    libpq-dev python-dev qgis2.14.7 python-qgis qgis-plugin-grass python-pip

WORKDIR /usr/src/app
ADD . .
RUN pip install -r requirements.txt
RUN chmod +x ./run.py
RUN chmod +x ./start.sh
ENTRYPOINT ["./start.sh"]

此命令正常工作,但此图像无法访问docker composer中指定的服务:

docker build -t habibi07/web
docker run habibi07/web

搬运工-compose.yml

web:
  restart: always
  image: habibi07/web
  expose:
    - "8000"
  links:
    - postgres:postgres
    - mongodb:mongodb
    - redis:redis
  volumes:
    - /usr/src/app/app/static
    - /root/projekty:/usr/src/app/app/static/projekty
  volumes_from:
    - data
  env_file: .env
nginx:
  restart: always
  build: ./nginx/
  ports:
    - "80:80"
  volumes:
    - /www/static
 volumes_from:
    - web
  links:
    - web:web

正如我所说使用docker时运行正常,当我尝试在docker compose文件中使用它时,问题就出现了。 Web服务日志显示此错误。

  

./ start.sh:line 2:gunicorn:command not found

这就是终点。

#!/bin/bash
gunicorn -w 8 -b :8000 app.main:app

我完全不知道为什么它不起作用。 Gunicorn当然都是使用pip和apt。我试过设置PATH env,但它也没有用。我知道我应该在基于python的图像上运行gunicorn,但我不能因为我需要访问在ubuntu基本映像上运行的qgis库。也许docker compose有它自己的背景,没有gunicorn?

0 个答案:

没有答案