r/docker•
Xymanek

Need help dockerizing my app

I have a symfony (PHP) application which I want to dockerize. The aim is to help with spinning up/down development/testing environment and easier updates (since the container(s) will be built and ready for prod). Also (hopefully) running on swarm/k8s in future.

However, I'm faced with a situation for which I cannot find any guides online. I have two background processes (jms job queue bundle runner and scheduler) which exit every 15 minutes and need to be restarted. Currently this is handled by supervisorD. Following docker's best practices I want to run each of them as a separate container. However I am not sure who should be responsible for restating the processes. Here are my options:

Docker/orchestrator

The first idea is to specify the process itself as an entrypoint and a restart policy so it's always up

  • Pro: No additional overhead, restarting done by existing software
  • Pro: Easier logging as output goes directly to stdout/stderr and can be easily fetched from docker
  • Pro: Easier management/scaling/monitoring as entire thing is managed by docker/orchestrator without an intermediate proxy (see cons in next section)
  • Con (?): If used with swarm/k8s in this form, it might cause too much "jumping" between hosts (creating small downtime segments) while it's crucial that these processes run all the time (1-2 second restart is fine)
  • Con (?): Is docker even intended to this kind of management? Will it work properly?
  • Con: logs/output are lost on restart

SupervisorD as an entrypoint

  • Pro: Proven to work
  • Pro: No host "jumping" when used with swarm/k8s
  • Con: Waste of memory - need to run 2x supervisorD instances (one for each container). This can be a problem as it's a small project which isn't launched yet - we are trying to cheap on infrastructure as much as possible and using 0.5gb droplet atm
  • Con: Requires a sidecar container for logging as output is piped to files, not stdout/stderr
  • Con: Requires additional monitoring (eg. in case supervisorD gives up on the process, docker/orchestrator will think that everything is ok)

I'm leaning towards #1 but since my knowledge of docker is quite limited I decided here first - maybe I got it wrong/missing something?

Posted Oct 28, 2017, 7:31 AM UTC

28
Loading comments…