title: How can I develop a LAMP web application using Docker, Puppet and Vagrant?
body: <p>In the dark ages, my usual setup for development of LAMP web applications was to test locally on my machine. PHP (in my case), the database and the web server were all installed natively.</p>
  <p>The server was set up with standard installs of Apache and MySQL, and I had multiple virtual hosts for different parts of the web application. When I was happy with the results I had on my local machine, I'd logged into the server and did <code>git pull</code> in the staging environment.</p>
  <p>Assuming everything was working as well on the server as it was on my machine, I'd do the same thing for production.</p>
  <p><strong>New beginnings…</strong></p>
  <p>So now I'm starting a brand new web application from scratch, and I want to do it &quot;the proper way&quot;. I've read up about Docker, Vagrant and Puppet (and <a href="https://en.wikipedia.org/wiki/Chef_(software)" rel="nofollow noreferrer">Chef</a>, although I personally prefer Puppet's system of dependencies rather than Chef's iterative process). Despite all the research I've done, there still seem to be several questions I can't seem to find answers for:</p>
  <p><strong>Should there be separate Docker containers for the web server (such as Apache), the database server (such as MySQL) and <em>each</em> part of the web application?</strong></p>
  <p>When I talk about <em>parts</em> of the web application, I mean things like <em>mysite.com</em>, <em>controlpanel.mysite.com</em>, etc. These &quot;parts&quot; will share the same database.</p>
  <p>Since Docker seems to provide ready-made containers for things like the web and database servers, it seems like those things at least should be in separate containers. Should the different parts of my web application be in separate containers, too?</p>
  <p><strong>Docker containers seem to be designed to be replaceable rather than me having to update the software inside them. What about the data they write that I don't want to lose?</strong></p>
  <p>The database server will manage files related to the content of my database (that I'll want to be backing up). The web server will be creating logs, and my web applications will be managing various files and caches, etc. All these files need to be written outside of the application's containers (because I might replace them when updating?), so where do they go? Straight into the host machine's file system? Or into a separate &quot;Docker Volume&quot;?</p>
  <p>If they go into Docker volumes, should I use a separate volume for the database, web server, application, etc.? Can I still easily access the contents using <a href="https://en.wikipedia.org/wiki/SFTP" rel="nofollow noreferrer">SFTP</a> from my local machine like I do now? I don't want to lose any convenience here!</p>
  <p><strong>Is it a good idea to use Puppet to create and manage the Docker containers, both for the development server and production server?</strong></p>
  <p>It seems Puppet has support for managing Docker containers directly, so this seems like a reasonably good way of easily setting up a server or the production environment (using Vagrant) from scratch.</p>
  <p>Hopefully I've asked some relevant questions; it would be great to get some proper &quot;best practices&quot; for development and production of LAMP-like web applications. it's just there doesn't seem to be much that I've found!</p>