PHP › PHP with Docker
How does Docker Compose let you define and run a complete multi container PHP application setup, including a web server, PHP-FPM, and a database, together?
IntermediateAnswer
Docker Compose lets you define an entire multi container application, such as an Nginx web server, a PHP-FPM application container, and a MySQL database container, all within a single YAML configuration file, specifying how they should be networked together and what environment variables or volumes each service needs, letting you start your complete local development environment with a single command rather than manually configuring and starting each individual container yourself.
services:
app:
build: .
volumes:
- .:/var/www/html
db:
image: mysql:8.0
environment:
MYSQL_DATABASE: myappReal-world example A development team defines their entire local environment, including PHP-FPM, Nginx, and MySQL, in a single docker-compose.yml file, letting any new team member get a fully working local development environment running with a single docker compose up command.