4 ms·
My one primary issue right now with Docker is that it's a little difficult to get something like Apache going, since it's a service. Docker obviously detects th
by andrewmunsell 13y ago
My one primary issue right now with Docker is that it's a little difficult to get something like Apache going, since it's a service. Docker obviously detects the command I pass in as finished, and then stops the container.
Here it's solved by turning the nginx daemon off and running the command directly, but is there a better way to run something like Apache (which runs as a service) to host PHP applications, without resorting to sending long running commands like "while true; sleep 1; done"?
I guess this kind of defeats the purpose of Docker, in a sense, since the project's more about isolating applications (which generally run as a long running process, a la Node.js). But, PHP is still a popular platform for development and I'd love to be able to try out Docker for some of my own PHP stuff versus spinning up entire VMs with Vagrant.
- shykes 13y agoHey Andrew, you can definitely run Apache+php as a docker container. Apache can run in the foreground with "httpd -D FOREGROUND", so that docker can monitor it. Then add a few layers to your Dockerfile with php, mod_php, 3d party php packes and your own code - you should be ready to go. Having docker monitor a foreground process has many advantages over the traditional "init script + self-daemonize" approach. Mostly it avoids reinventing the wheel. For example each process doesn't have to worry about logging, service registration/discovery, etc. I would argue it is closer to the Unix way :)
- sneak 13y agoIt also has the added advantage of stopping (and presumably automatically restarting, or at least triggering an alarm) a container when the service dies, something a daemonized version with a "while true; sleep" one would not. This is something baked into the design of djb's daemontools (as well as later efforts in that realm like launchd and upstart), something the traditional shell-script startup stuff always got wrong. Failure detection is your friend.
- andrewmunsell 13y agoYeah, I guess that makes sense. Thanks for the response!
- nickstinemates 13y agoAndrew - check out the latest article to see how I get nginx (a webserver like Apache) to run the site you're viewing. Just re-click the link.
- ecaron 13y agoI recently tried out the instructions at http://robknight.org.uk/blog/2013/05/drupal-on-docker/ http://robknight.org.uk/blog/2013/05/drupal-on-docker/ (70% intro to Docker, 30% PHP+Apache), and I think it put me on the right track. I still have a long ways to go (like getting PHP-FPM working in this environment) but Rome wasn't built in a day...