Docker and docker-compose Setup
Docker and docker-compose setup
Docker solves one specific problem: "it works on my machine but not on the server". The environment is described in a file, and it is identical everywhere — on a developer's laptop, on staging, on the live server.
What it is genuinely useful for
- an identical environment for a team — a new developer starts with one command;
- several projects with different PHP versions on one server without conflicts;
- a staging environment identical to production;
- quickly checking compatibility with a new PHP or database version.
What is included
An environment definition for your project: web server, the PHP version you need with its extensions, database, cache. Volume configuration for data that must survive a restart. Separate configurations for development and production. Short start-up instructions.
What to be aware of
Data does not live inside the container. The database, user uploads and logs belong in volumes, otherwise a restart destroys them. This is the most common mistake on first acquaintance.
For a single simple site it may be overkill. If you have one store on one server and nobody else touches it, Docker adds work without giving you the benefits.
Filesystem performance. On some configurations, file access from inside a container is slower — for projects with large file counts that is noticeable and needs tuning.
Tags: docker, containers, devops, nginx, deployment