A Docker-Compose PHP Environment From Scratch | docker compose php
Containerization.Peopleareravingaboutit.Buthowdowegetstarted?TheseDockerfilethingsseemsoforeign,andbesides,howdowegetdifferentcontainersforourdifferentservices?Afterall,ifweshovedthemintoone,itskindofdefeatingthepurpose.Fearnot!Itseasierthanyouthink.WelluseabasicPHPenvironmenttogothroughtheprocess.PlanningOurStartingContainersOnethingthatmakesDockersopowerfulistheabilitytodefinedifferentcontainersfordifferenttasks.Thisallowsustoorganizeourfileslogically.Weregoingtostartwiththeverybasicsneede...
Containerization. People are raving about it. But how do we get started? These Dockerfile things seem so foreign, and besides, how do we get different containers for our different services? After all, if we shoved them into one, its kind of defeating the purpose.
Fear not! Its easier than you think. Well use a basic PHP environment to go through the process.
Planning Our Starting ContainersOne thing that makes Docker so powerful is the ability to define different containers for different tasks. This allows us to organize our files logically. Were going to start with the very basics needed to get our system up and running. For a PHP application, thats a server (well use nginx), the PHP process manager (php-fpm), and a database (MariaDB). If we need to grow in the future, we can follow the same process and have a new node in no time. Well also create a src folder for our PHP files.
Heres what our starting folder structure looks like: