As others have pointed out, you are adding too much to your containers. Each application should be deployed it its own app container separate from any database or web container. It is not advisable, for example, to have a Tomcat container and deploy several applications into it. This defeats the purpose of using containers to isolate workloads. Instead, create multiple images from your base
Tomcat image, each with a single application inside. For example:
Dockerfile that contains the first app:
COPY FirstApplication.war /usr/local/tomcat/webapps/
Dockerfile that contains the second app:
COPY SecondApplication.war /usr/local/tomcat/webapps/
docker build to create separate images from which you will instantiate your containers. Docker uses a
layered filesystem. Layers are reusable. Both of these images will share the common layers from
tomcat:9-jre8-alpine so that the only additional disk space will be the apps themselves. This should take up exactly the same amount of disk space as placing multiple apps into one container but it has the added benefit that you can now redeploy a single application without taking any of the others down. I also selected the
Alpine version of Tomcat which is only 108MB in size instead of 463MB in size. A significant savings in disk space.
Your databases should be in their own containers as well with external volumes mapped to persistent storage on your VM so that your data will (1) survive container restarts and (2) be easily backed up. Likewise for any web front ends like Apache or Nginx being in separate containers. This has the added advantage of being able to separately scale the web, app, and db containers as needed instead of scaling the entire stack. This will maximize the limited resources that you have.