简体   繁体   English

Dockerfile与tomcat + mysql + filesystem app

[英]Dockerfile with tomcat + mysql + filesystem app

Being a newbie to docker: 成为码头工人的新手:

Right now I have a java web app running on tomcat, using mysql as database server, and writes to/reads from the filesystem. 现在我有一个在tomcat上运行的java web应用程序,使用mysql作为数据库服务器,并从文件系统写入/读取。

Am I supposed to put tomcat, mysql and filesystem resources on different containers (using official tomcat and mysql dockerfiles) and connect them somehow, OR do I write a dockerfile myself that combines everything in a single container? 我应该把tomcat,mysql和文件系统资源放在不同的容器上(使用官方的tomcat和mysql dockerfiles)并以某种方式连接它们, 或者我自己编写一个dockerfile,它将所有内容组合在一个容器中?

In the second case should I start with a base dockerfile, say an ubuntu one, and add mysql, java and tomcat to it by copying from their respective official dockerfiles? 在第二种情况下,我应该从一个基本的dockerfile开始,比如一个ubuntu,然后通过复制它们各自的官方dockerfiles来添加mysql,java和tomcat?

You can do either, but your first option is going to be more maintainable and more scalable in the long run. 你可以做任何一种,但从长远来看,你的第一个选择是更易于维护和更具可扩展性。

Composing a service from multiple containers means that you can take advantage of the work other people have already done to create standard images (like the mysql image). 从多个容器组成服务意味着您可以利用其他人已经完成的工作来创建标准映像(如mysql映像)。 It also means that you can independently scale different parts of your application. 这也意味着您可以独立扩展应用程序的不同部分。 Need more web front-ends? 需要更多网络前端? No problem! 没问题! Need to use an existing database server or cluster instead of a container? 需要使用现有的数据库服务器或集群而不是容器? No problem! 没问题!

A tool like docker-compose will help you maintain an application built from multiple containers. docker-compose这样的工具可以帮助您维护从多个容器构建的应用程序。

There are a number of quickstarts (eg, this one ) that might help you get started. 有许多快速入门(例如, 这一个 )可能会帮助您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM