简体   繁体   English

使用Dockerfile在PostgreSql中运行Tomcat

[英]Running Tomcat with PostgreSql using Dockerfile

I want to run a Tomcat with PostgreSql database within the same Dockerfile. 我想在同一Dockerfile中使用PostgreSql数据库运行Tomcat。

I have the following Dockerfile 我有以下Dockerfile

FROM tomcat:8-jre7

MAINTAINER "Sonam <mymail@gmail.com>"

RUN apt-get -y update

Add simplewebapp.war /usr/local/tomcat/webapps/

RUN apt-get update && apt-get -y upgrade

FROM postgres

When I run the docker image, I can't access the Tomcat like I could if I comment out the postgres. 运行docker映像时,如果注释掉postgres,则无法访问Tomcat。 How do I get Postgres running and Tomcat too? 如何使Postgres和Tomcat运行?

thanks 谢谢

You can only take one image as your base, just the same as you can only have one OS installed. 您只能以一个映像为基础,就像只能安装一个操作系统一样。

If you need to have two applications installed, then you need to build your own container - either starting from one and running the sequence of commands in the Dockerfile you need to install the other app, or just start from a base OS image, and install both. 如果需要安装两个应用程序,则需要构建自己的容器-从一个容器开始运行Dockerfile中的命令序列,然后安装另一个应用程序,或者仅从基本OS映像开始并安装都。

Alternatively - why do you need them in the same container? 或者-为什么您需要将它们放在同一容器中? Something like --link might do what you want, more effectively. 诸如--link类的--link可能会更有效地满足您的需求。 Just run two containers, and link them. 只需运行两个容器,并将其链接。

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

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