简体   繁体   中英

Running Tomcat with PostgreSql using Dockerfile

I want to run a Tomcat with PostgreSql database within the same Dockerfile.

I have the following 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. How do I get Postgres running and Tomcat too?

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.

Alternatively - why do you need them in the same container? Something like --link might do what you want, more effectively. Just run two containers, and link them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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