0

My Project bases on python-flask and celery with RabbitMq.

So I have to run 2 long services in the one container:

Two services:
1. gunicorn -w 64 -b 127.0.0.1:8888 manage:app
2. celery worker -A celery_worker.celery --loglevel=info

Those 2 services are both running as long time commands

I don't know how to write the Dockerfile to achieve my purpose.

I tried this:

CMD ["gunicorn -w 64 -b 127.0.0.1:8888 manage:app", "celery worker -A celery_worker.celery --loglevel=info"]

But it does not works.

Before I decided to use docker in my project, I used supervisor for execute those two commands simultaneously. But the supervisor has some problems in docker container which I couldn't solve(DETAIL).

So I want to know how to achieve my purpose that running 2 long time services in a docker container, how to write this Dockerfile. I want to execute "docker stop" that those 2 services can stop, "docker start" that those 2 services can start.....

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Jolly23
  • 879
  • 1
  • 8
  • 13
  • See supervisor or s6 or daemontools – user2915097 Jun 09 '17 at 05:33
  • Normally these two service should be run as seperate docker containers. There is `docker-compose` which allows you to confirgure a group of services that is run with one command and also allows scaling of single services, e.g. "now I eant to have five celery workers". – Klaus D. Jun 09 '17 at 05:51
  • You can run 2 containers from the same image, which you should be doing here. – jordanm Jun 09 '17 at 06:01
  • Please try to read through answers for similar question https://stackoverflow.com/questions/19948149/can-i-run-multiple-programs-in-a-docker-container – webdizz Jun 09 '17 at 06:03
  • Possible duplicate of [Can I run multiple programs in a Docker container?](https://stackoverflow.com/questions/19948149/can-i-run-multiple-programs-in-a-docker-container) – webdizz Jun 09 '17 at 06:08
  • I found some thing here[Run multiple services in a container](https://docs.docker.com/engine/admin/multi-service_container/) – Jolly23 Jun 09 '17 at 06:39

0 Answers0