Back to results for “Deployment”
PHP › PHP with Docker

How should a team design their Docker based deployment pipeline for a PHP application to ensure the exact same tested image is what actually reaches production?

Advanced

Answer

A reliable pipeline builds a single Docker image once as part of the continuous integration process, runs the application's automated test suite against that exact same built image, tags it uniquely, typically with a commit hash or version number, pushes it to a container registry, and then deploys that exact same already tested and tagged image to each subsequent environment, from staging through to production, rather than rebuilding the image separately for each environment, which eliminates any risk of subtle differences creeping in between what was tested and what actually gets deployed.
docker build -t myregistry/myapp:abc123 .
docker push myregistry/myapp:abc123
docker run myregistry/myapp:abc123
Real-world example A company's deployment pipeline builds and tests a single Docker image tagged with the specific commit hash, then deploys that exact identical image first to staging and later to production, guaranteeing there is never any discrepancy between what was tested and what customers actually use.

Common follow-ups: What is a container registry and how does it fit into this deployment workflow?;How do you handle database migrations as part of a Docker based deployment process?