Introduction to Docker Boilerplate for PHP applications

container photo

Docker can provide you a similar environment as the production environment even on your local development platform with all services like Webserver, PHP, MySQL, PostgreSQL, email and other. Docker Boilerplate can help you to get stared with Docker with a fully preconfigured and customisable environment.

Some weeks ago I’ve created a nice and clean Docker Boilerplate for PHP applications with most common services like Apache HTTPd, Nginx, MySQL, PostgreSQL, Mail-Handling and other stuff. The first version was for TYPO3, all later versions are general for any PHP application.

The focus of this Boilerplate is the customisability to use it as template for any PHP based project like TYPO3, Symfony and other frameworks. This Boilerplate is not tied to much to any framework but provides some configuration for existing frameworks.

All services are configured to output enough informations as possible to make development fun again.

Apache and PHP-FPM access log (with request time and memory and cpu usage):
Apache access log

PHP-FPM error log:
PHP-FPM error log

PHP-FPM slow log:
PHP-FPM slow log

To run this Docker Boilerplate you need a Linux with Docker. If you’re working under Windows or MacOS i can recommend a Vagrant VM with preinstalled Docker.

If you don’t have any Vagrant VM yet you can try my Vagrant Docker VM which also provides an mail sandbox, SSH, HTTP reverse proxy (for Docker Boilerplate instances)  and Samba service. Host to guest sharing is available and it’s compatible to VirtualBox, VMware Fusion, VMware Workstation and Parallels Desktop.

I would not recommend Boot2docker for web development because of the missing host to guest file sharing (Samba or fast VM specific sharing). Also Windows developers need their development environment and within a Busybox you can’t develop nicely.
Also some debug tools like strace or tshark (network sniffer) are missing.
Boot2docker is nice if you only want to run services like databases but IMHO not for real development. And because of the better speed and stability of VMware or Parallels compared to VirtualBox.

Any comments or suggestions? Leave a comment 🙂

References:

I'm working as DevOps (software developer and linux administrator) in a TYPO3 agency in Stuttgart. I love OpenSource technologies like Linux and PHP and I'm want to share knowledge and experience.

2 Comments

  1. Florian (PanadeEdu) Tatzel

    2015-06-20 - 3:39 pm
    Reply

    I am all in with this Boilerplate, it helped me to get Docker up and running.
    Not only that, I learn parts of using Docker bit by bit, while using it for development and fixing smaller Issues.

    I believe Docker is the future of virtualisation and its extensions.
    What baffles me always again is, while it seems normal to handle virtualisation and deployment processes, many people don’t and it’s kind of depressing how the pure slothness of some companies lead to crazy workflow processes which can break with a breeze.
    Working on a stable but yet customisable system is what every developer needs to do, at least in always changing environments like the web development business.

    Thanks for this work Markus,
    I will continue to contribute as I can to make this thing for everyone. 😀
    Keep it up!

    • Markus Blaschke

      2015-06-21 - 11:36 am
      Reply

      Thanks for your contributions. My goal is to create a easy and customisable Docker Boilerplate for each project 🙂

Leave a Reply