Let’s sum up what we’ve achieved:

  • Create a Docker image containing Linux Apache and PHP with xdebug enabled
  • Use a public and official MySQL docker image
  • Use of docker-compose to ensure the start-up of 2 containers based on the 2 mentioned images, and also to ensure the communication between these 2 containers
  • docker-compose allowed us to map a folder of the container to the source folder of our PHP project.
  • Use of Visual Studio Code to open our project and debug it (using breakpoints)

Also remember that we have placed our different files related to the docker part inside a .devcontainer/ folder at the root of our PHP project which allows you to put it in a repository of your version control software such as Git, SVN or other.

And so you can easily share this with other developers and also provide version control of your docker configuration.

It is important to keep in mind that this docker configuration is valid for a development environment, but for a production release you should:

  • add security on MySQL (running the mysql_secure_installation script, other security settings, …)
  • disable xdebug
  • manage access to your project source code in another way
  • secure some docker part for a production environment

In conclusion, I hope you liked this pampered docker, and that you will pamper your own containers in the future! 🙂