Docker in the Real World: Lessons, Pitfalls, and the Quest for a Perfect Container Architecture
After experimenting with Docker to isolate PHP‑FPM and Nginx services, a small startup shares the challenges they faced—from link networking quirks and service discovery with Consul, to CI image builds, log handling, monitoring, and the hidden costs of container restarts—offering practical insights for anyone adopting containerization.
Project Environment
We use a standard PHP stack (PHP‑FPM + Nginx) on Alibaba Cloud ECS, with the database also provided by Alibaba Cloud.
Motivation
Although a small startup should avoid unnecessary complexity, we needed Docker to test performance improvements (e.g., HHVM, PHP7) and to isolate problematic services that caused high memory usage and timeouts.
A Small Test
Following Docker’s philosophy, we ran PHP‑FPM and Nginx in separate containers, exposing the PHP‑FPM port to Nginx. Initially we used Docker’s link feature, but it proved unreliable when containers restarted or when multiple instances were required. We switched to Consul for service discovery (see related article).
Code resides on the host and is mounted into containers. We split APIs across several containers, performed stress tests for resource isolation, and observed significant performance gains with HHVM. The architecture is illustrated below.
Logging and Monitoring
We first mounted a host directory for logs, then replaced it with a dedicated Logstash container to collect logs from all services. Monitoring is handled by OneAPM, though other open‑source tools are also possible.
The Perfect Path
To achieve a truly container‑native workflow, we adopted a Docker‑based CI pipeline: each release builds a new image (including code, dependencies, and preprocessing), pushes it to a registry, and each node pulls and restarts the container. The process is shown below.
Facing Reality
While the CI flow is automated, it adds minutes to each deployment because building and pushing images is slower than a simple git pull. Container restarts are also costly; PHP‑FPM handles SIGTERM slowly, making a restart of dozens of containers time‑consuming. Upgrading to Docker 1.10 introduced intermittent port‑connectivity issues that required manual network probes to resolve.
Continuing Exploration
Future plans include using Docker Swarm for simple clustering and evaluating Mesos or Kubernetes for larger scheduling needs. The key takeaway is that no architecture is perfect; the best choice balances project requirements, team expertise, and added complexity.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
