I am new to docker, trying to run multiple python processes in docker. Though it's not recommended, however, it should work as suggested here "https://docs.docker.com/engine/admin/multi-service_container/"
My Dockerfile :
FROM custom_image
MAINTAINER Shubham
RUN apt-get update -y
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["/bin/bash"]
CMD ["start.sh"]
start.sh :
nohup python flask-app.py &
nohup python sink.py &
nohup python faceConsumer.py &
nohup python classifierConsumer.py &
nohup python demo.py &
echo lastLine
run command :
docker run --runtime=nvidia -p 5000:5000 out_image
Is it possible to run multiple processes without supervisord or docker-compose?
update: not getting any error, only "lastLine" is getting printed and docker container exits.
Docker docs has examples of how to do this. If you're using Python, then using supervisord
is a good option.
FROM ubuntu:latest
RUN apt-get update && apt-get install -y supervisor
RUN mkdir -p /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY my_first_process my_first_process
COPY my_second_process my_second_process
CMD ["/usr/bin/supervisord"]
The advantage of this over running a bunch of background processes is you get better job control and processes that exit prematurely will be restarted.