[英]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. 我决定在我的所有项目中开始使用docker,并且对部署方面的最佳实践感兴趣。
If I have a local docker environment, that is running a php-apache, mysql, and redis service, what's the best strategy when deploying? 如果我有一个本地docker环境,正在运行php-apache,mysql和redis服务,那么部署时的最佳策略是什么? 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)?
您是否有用于生产的自定义docker-compose配置,该配置会删除redis和mysql服务(假设您希望将它们放在自己的专用服务器上)?
There are a number of viable ways to run PHP containers in production, so it's a little hard to answer your question comprehensively. 有许多可行的方法可以在生产环境中运行PHP容器,因此很难全面回答您的问题。 I'll offer a few options:
我将提供一些选择:
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 ).
您可能想从只为数据库运行一个容器或通过使用托管数据库服务开始,因为跨多个容器扩展数据库可能会变得很复杂(但是这里介绍了如何使用MySQL进行操作 )。
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. 因此,对于部署,目前最好的选择是仅部署已配置的Web服务器以及任何其他无状态服务器需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.