박진곤
박진곤

Reputation: 11

Unable to run docker container using python uwsgi

I'm building a small Python(flask) app.

The Image is built successfully but Container is not running. When I run docker ps, no running Container is found. Also docker logs shows uwsgi not found

identidock.py:

from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_docker():
    return 'Hellow docker!\n'

if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0')

Dockerfile:

FROM python:3.6

RUN pip install Flask==0.10.1
RUN pip install uWSGI==2.0.17
WORKDIR /app
COPY app /app

CMD ["uwsgi", "--http", "0.0.0.0:9090". "--wsgi-file", 
"/app/identidock.py", "--callable", "app", "--stats", "0.0.0.0:9191"]

Commands ran:

sudo docker build -t identidock .   <<< no problem
sudo docker run -d -p 9090:9090 -p 9191:9191 identidock << no problem
sudo docker ps     << empty   
sudo docker logs <container ID>  > >>/bin/sh: 1: [uwsgi,: not found

Upvotes: 1

Views: 1535

Answers (1)

mauricubo
mauricubo

Reputation: 331

if you are building the docker image with this line CMD ["uwsgi", "--http", "0.0.0.0:9090". "--wsgi-file", "/app/identidock.py", "--callable", "app", "--stats", "0.0.0.0:9191"], you have a dot after "0.0.0.0:9090" that you need to change by a ,.

Docker file should be:

FROM python:3.6

RUN pip install Flask==0.10.1
RUN pip install uWSGI==2.0.17
WORKDIR /app
COPY app /app

CMD ["uwsgi", "--http", "0.0.0.0:9090", "--wsgi-file", "/app/identidock.py", "--callable", "app", "--stats", "0.0.0.0:9191"]

This should work...

Upvotes: 2

Related Questions