Chapter

A real project: dockerizing a PHP app

Put it all together by packaging a PHP/Laravel app with a database using Compose.

Docker Basics 2 Lessons from courses

About this chapter

Time to use everything you've learned on a real, developer-focused example: running a PHP/Laravel application and its database with Docker Compose.

Lessons from courses

  1. 1 A Dockerfile for a PHP app Write a Dockerfile for a PHP/Laravel app: pick the php:8.4 base image, install extensions, copy code and install Composer dependencies.
  2. 2 Wiring the app and database with Compose Write a docker-compose.yml that builds your PHP/Laravel app image and connects it to a MySQL database, then run migrations with compose exec.
Docker Basics Go to course