While @Thomasleveil's answer is already very good and covers all the important parts, I would like to add additional points.
Tramp, Puppet / Chef and docker writer
When you create a virtual machine using Vagrant, you usually use Puppet or Chef to install the necessary packages for your server ... along with several shell scripts. PuPHPet is a great source for setting up the LAMP stack in a virtual machine and learning how Puppet and Vagrant work together in a more complex setup. An alternative is Protobox .
When you use Docker containers with Vagrant in the same way as with virtual machines. Then, with vagrant up you essentially launch vagrant up containers with the Docker provider. Vagrant will build containers for you from the Docker file or use an existing image more or less similar to docker-compose ( fig ) and run them.
The main reason for choosing Vagrant for your Docker installation is if you or your team partially work in a Windows environment, as Vagrant allows you to keep your setup consistent no matter what your host system is (see Host VM ).
If you use OS X, you can use docker-compose with a virtual virtual machine, if you are running Linux, you can use Docker natively. You can also always log in to boot2docker (or another Docker Host virtual machine) via ssh , whether you are on Windows or OS X.
Note. You should not use SSH in your containers, but this is a different topic.
As of February 2015
docker-compose feels a little more spectacular for me, and it also starts, stops and restores containers more efficiently.
The advantage of Vagrant is to specify another host virtual machine, for example. per project, if you prefer this setting.
Note: It also provides a Docker mechanism, which is more related to the Puppet build process.
Should there be separate Docker containers for the web server (e.g. Apache), database server (e.g. MySQL) and each part of the web application?
When using Docker containers, you mostly use single isolated processes. Using a supervisor should be avoided and also not necessary for the LAMP stack.
So my answer is definitely: Yes, there must be separate containers!
When I talk about parts of a web application, I mean things like mysite.com, controlpanel.mysite.com, etc.
It depends on your needs, I suggest you read the 12factor documentation, which describes important things that you need to take care of in a very detailed way.
Docker containers appear to be intended to replace, not to update software within. What about the data they write that I do not want to lose?
In addition to @Thomasleveil's answer, I would also recommend a separate backend for storing users like Amazon S3, SFTP or WebDAV.
In my opinion, your web application container should be considered as a client application that accesses your database and backends (services) of data storage, and also not rely on data from volumes when working in a production environment.
Is it good to use Puppet to create and manage Docker containers for both the development server and the production server?
I don’t know about the possibilities of Puppet orchestration, but to create containers, if you use Vagrant, I don’t see the need for Puppet, due to Docker’s own assistant for Vagrant.
Bonus
For all the things described above, you can see my 12factor PHP-template application based on the Yii 2.0 Framework with the LAMP docker stack. With Docker, you can also easily connect reverse proxies or containers for testing selenium into your project, as they exist as pre-build images and can be downloaded and configured in a few minutes and started in a few seconds.