An everyday local development environment for PHP Developers. Remix of https://github.com/pvtl/docker-dev by @pvtl aka Pivotal Agency.
This is a set of Docker images to spin up a LAMP stack (Linux, Apache, MySQL and PHP) for developing locally. It's perfect for local development because you can very simply add new sites to specified directory and they're magically accessible as a subdomain of your chosen hostname (e.g., ~/sites/info maps to http://info.localhost/).
It includes all the required dependencies for everyday PHP development with common tools like Laravel, Wordpress and Magento (1 & 2). Specifically:
Default:
- Apache
- PHP 7.4
- Composer (latest)
- Node.js (16.x) & NPM (latest)*
- Yarn (latest)*
- PHPCS (with Wordpress code standards added)*
- Wordpress CLI*
- fish
- Mailhog (latest)
- MariaDB 10.3
Optional:
- PHP 5.6, 7.0, 7.1, 7.2, 7.3 and 8.0
- Memcached 1.x
- Redis 6.x
- HTTPS (SSL for localhost)
- Blackfire (latest)
* Available in latest 2x PHP containers
The environment features clever domain mapping to allow you to run code for various platforms. Sites are accessible from the following URLs (by default it's http://<website>.localhost, however APACHE_HOSTNAME can modified in .env to point to a different hostname):
- http://classic-php.php56.{APACHE_HOSTNAME} (e.g., http://classic-php.php56.localhost)
- Will map to
~/Sites/classic-phpand use PHP 5.6
- Will map to
- http://laravel.php74.pub.{APACHE_HOSTNAME}
- Will map to
~/Sites/laravel/publicand use PHP 7.4
- Will map to
- http://another-project.{APACHE_HOSTNAME}
- Will map to
~/Sites/another-projectand use the default version of PHP (currently 8.0)
- Will map to
You'll first need to install Docker Desktop (or Docker on Linux).
On Windows, we strongly recommend running these commands inside a WSL2 container for best performance
# Clone the repo
git clone https://github.com/mavaddat/docker-dev && cd docker-dev
# Create & update relevant config - For example:
# - Point sites to your sites directory
# - Set user/group ID's
# - Add optional services (e.g., extra PHP versions, PHPMyAdmin, Memcached etc)
cp .env.example .env
# Start the environment
docker-compose up -d
# The containers are now running. You can now:
# - Open a website in your browser using <DIRECTORY NAME>.{APACHE_HOSTNAME} (see domain mapping notes above)
# - Open a terminal window into one of the containers, via `docker-compose exec <CONTAINER NAME> bash`Open a terminal window, browse to this project's folder and run:
# 1. Pull from Git
git pull
# 2. Erase previous containers
docker-compose down --remove-orphans
# 3. Get latest docker images
docker-compose pull
# 4. Rebuild Dockerfiles from scratch (inc. pull parent images)
docker-compose build --pull --no-cache --parallel
# 5. Start the new env
docker-compose up -d
# 6. Erase any unused containers, images, volumes etc. to free disk space.
docker system prune --volumesThis will also install the latest versions of all tools (e.g., PHP, Redis, Node.js etc.)
The Docker Engine must be running and commands must be run within this repo's root.
| Command | Description |
|---|---|
docker-compose start |
Start all containers |
docker-compose stop |
Stop all containers (keeps any config changes you've made to the containers) |
docker-compose up -d --build --no-cache |
Recreate all containers from scratch |
docker-compose down |
Tear down all containers (MySQL data and Project files are kept) |
docker-compose exec php80-fpm fish |
Open a fish terminal in the PHP 8.0 container |
docker-compose logs php80-fpm |
View all logs for PHP-FPM 8.0 |
docker-compose ps |
Show which containers are running |
- 🚥 Connections
- ❓ FAQs

