Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
854 views
in Technique[技术] by (71.8m points)

running two separate Python-Flask api via a single docker file

I want to run two different python api files running on different ports via a single container.

My docker file looks like:

FROM python:3.7-slim-buster

RUN apt-get update && apt-get install -y libgtk2.0-dev cmake libpoppler-cpp-dev poppler-utils tesseract-ocr

WORKDIR /app

COPY requirements.txt ./

RUN pip install --no-cache-dir -r requirements.txt 



COPY . .

RUN chmod a+x run.sh

CMD ["./run.sh"]

And the .sh file looks like:

#!/bin/bash

exec python3 /app1/numberToWord.py &
exec python3 /app2/dollarToGbp.py &

While the docker build is a success without any error, the docker run doesn't throw any error and exits the command line. I'm curios to know where is it failing, any insight is highly appreciated.

question from:https://stackoverflow.com/questions/65617505/running-two-separate-python-flask-api-via-a-single-docker-file

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try using nohup to ignore hangup signal

Ex:

#!/bin/bash

nohup python3 /app1/numberToWord.py &
nohup python3 /app2/dollarToGbp.py &

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...