xil3
xil3

Reputation: 16439

Best deployment strategy with docker compose (LAMP stack)

I decided to start using docker in all my projects, and I'm interested in best practices, when it comes to deployment.

If I have a local docker environment, that is running a php-apache, mysql, and redis service, what's the best strategy when deploying? Do you have a custom docker-compose config for production, which removes the redis and mysql services (assuming you'd want those on their own dedicated server)?

Upvotes: 2

Views: 2302

Answers (2)

karllhughes
karllhughes

Reputation: 300

There are a number of viable ways to run PHP containers in production, so it's a little hard to answer your question comprehensively. I'll offer a few options:

  • Use a container hosting service like Docker Cloud to host your PHP code with the built-in Apache service.
  • Use an orchestration service (like Swarm or Kubernetes) hosted on your own servers. You'll have more setup here, but it will also give you more control. There are also services that make this easier like Rancher or Codemason.
  • Run docker-compose on one machine. Sure, it's not horizontally scalable, but if you're just working on a side project or small app, you can run all your containers on one server to start.

As a note on database containers, you can containerize your database, and assuming that you put the actual data in a volume and have a sensible backup system in place there's no reason that containers won't be safe. You probably want to start by running just one container for your database or by using a hosted database service as scaling a database across multiple containers can get complicated (but here's a little bit about how you might do it with MySQL).

Upvotes: 2

xil3
xil3

Reputation: 16439

I guess I'll be answering this myself.

After some more intensive digging, I found out that it's not a very good idea to deploy the database within a container. If I use swarm, it would be very difficult to maintain data integrity across the whole system.

Looks like most people just host the database separately, and only containerize the db in local development environments.

So for deployment, best option right now is to deploy just the configured web server and any other stateless server requirements.

Upvotes: 1

Related Questions