Docker for PHP Developers

Second Edition updated for PHP 8

Docker for PHP Developers will teach you how to use Docker and PHP to create clean, repeatable development environments that are easy to understand.

Learn how Docker can simplify your PHP development setup and make it simple to share your environment with others. You will learn how to use Docker and PHP with confidence.

Buy the Book Get a Sample

Get a Free Book Sample

Try before you buy with a free sneak peek! Enter your email address and I'll send you a sample PDF from my book. You will also be added to my newsletter where I share tips and tricks about PHP, Docker, and web development.

What does the Book Cover?

Docker for PHP Developers is a book that helps you master Docker as a full time PHP development environment.

Development Tools

  • Learn how to manage containers
  • Learn how to use Docker Compose
  • Use XDebug with Docker
  • Use PHP Composer with Docker

PHP Environment

  • Building PHP containers from scratch
  • Installing PHP modules
  • Managing module INI files
  • Per-environment configuration

CLI Applications

  • Create a CLI application image
  • Learn how to log CLI output with Docker
  • Learn to use build arguments

Web Servers

  • Nginx + PHP-FPM
  • Explore Caddy and FrankenPHP
  • Repeatable development envs with Docker

What's Inside the Book

Chapter 1 Introduction to Docker

We'll jump right in and install Docker, with installation steps for Mac OS X, Linux, and Windows. Then, you'll run your first container to verify that your setup is working properly.

Chapter 2 PHP Container Basics

Learn your way around Docker with hands-on commands. We'll start off with the basics so you can learn how build your first Docker image from scratch and how to run it. We'll then go over customizing a PHP INI file.

Chapter 3 LAMP with Docker

Learn how simple it is to build your own LAMP stack with Docker, without any 3rd party tools. You will also learn how to install and configure PHP modules, all while versioning your configuration in your projects.

Chapter 4 Development Tools

Learn how to master Xdebug with Docker with a step-by-step guide that shows you how to install Xdebug with a reusable configuration. You'll also learn how to remove Xdebug when you deploy Docker to production environments.

Chapter 5 Composer PHP

Are you curious how to use PHP Composer with Docker? You will Learn how to install the PHP Composer CLI and install your application dependencies while building a Docker image. Learn how to install private composer repositories without leaving a trace of sensitive API keys or SSH credentials.

Chapter 6 PHP-FPM and Webservers

Running a Webserver in Docker is a little different than on a traditional server. We cover installing Nginx and PHP-FPM and how they communicate in between Docker containers.

Chapter 7 Exploring More Web Server Options

Continue learning how to run PHP applications in Docker using Caddy and FrankenPHP. Learn how to use modern server alternatives with PHP-FPM.

Chapter 8 Custom Commands

Go beyond the basics of running a container with custom commands and learn how to customize your application startup and runtime. Learn how to create a CLI application, which walks you through important concepts like logging, versioning, and more.

Nice Stuff People said about the First Edition

Get Docker for PHP Developers

Docker for PHP Developers, Second Edition (2025)

Docker for PHP Developers, Second Edition Book

Learn how Docker can simplify your PHP development setup and make it simple to share your environment with others. You will learn how to use Docker and PHP with confidence.

  • Second edition updated for PHP 8 and Laravel 12
  • Latest Docker and Docker Compose versions
  • The 170-page Docker for PHP Developers Book
  • Basic ePub and Mobi formats included

Paul Redmond

About the Author

Hello! I'm Paul Redmond. I'm a full stack developer writing stuff with Laravel and Docker. I am a staff writer for Laravel News.

I am the author of Writing APIs with Lumen, now published with Apress as Lumen Programming Guide (2016). You can find me on X as @paulredmond.