Hi all,
I have one question regarding of what is the best practice when comes to starting multiple services in one container. For example; I have one Ubuntu based Dockerfile in which I have to install Grav. In order this to work; I need to have nginx and php-fpm services running when image is started.
Currently, I am using monit with such configuration that it starts both nginx and php-fpm. Monit itself is called at the end of the Dockerfile as:
# Run services via Monit daemon
ENTRYPOINT service monit start && /bin/bash
It works, but I am not sure is this the ‘Docker way’ and if not; shall I take different approach?
The docker way would be to split the services up, but if you want to put it all in 1 container, it will work.
I think most people uses supervisor, you can check out my example here: CentOS 7 systemd
In this case I would say that you are doing it right. I would consider the Nginx/PHP/Grav CMS to be one entity. Splitting them would not make any difference. You can run a pure Nginx and route it to the PHP/Grav-instance if you want, but more separation than that is not needed in this case. Then it is up to compose to make sure that you have your PHP/Grav-container up and running before starting Nginx.
I always wrap my entrypoint in a entrypoint.sh file that I add. That way, if I need to test something else, like running it in debug mode, I can easily mount a new entrypoint.sh file when starting the container.