Skip to main content

Tomcat

What is Tomcat?

Apache Tomcat is a Java Servlet container that runs Java web applications packaged as WAR files. Laradock runs it from the official tomcat Docker image.

Start Tomcat

./laradock start tomcat

Stop Tomcat

Stopping just pauses the container; your deployed WAR files and logs are untouched (they live on your host, under DATA_PATH_HOST):

./laradock stop tomcat

To delete the container entirely (your webapps and logs on disk are still untouched):

./laradock remove tomcat

Configuration

Settings live in tomcat/defaults.env and can be overridden in your own .env:

VariableDefaultWhat it does
TOMCAT_VERSION9.0Image tag from the official tomcat Docker Hub page.
TOMCAT_HOST_HTTP_PORT8080Host port Tomcat is published on (container always listens on 8080 internally).

Tomcat runs from a prebuilt image (no local Dockerfile), so after changing .env a restart is enough, no rebuild step exists for this service:

./laradock restart tomcat

Deploy a WAR file

Drop a .war file into DATA_PATH_HOST/tomcat/webapps, it's mounted straight into Tomcat's own webapps directory, so Tomcat picks it up and auto-deploys it without a rebuild:

cp your-app.war "${DATA_PATH_HOST}/tomcat/webapps/"

Open http://localhost:8080 to reach the Tomcat welcome page, or http://localhost:8080/your-app once your WAR has deployed. Logs are written to DATA_PATH_HOST/tomcat/logs, also mounted from the host.

Undeploy a WAR file

Tomcat auto-deploys by unpacking the WAR into a matching folder next to it. To remove an app, delete both the archive and its exploded folder, then Tomcat drops it on the next check:

rm -rf "${DATA_PATH_HOST}/tomcat/webapps/your-app.war" "${DATA_PATH_HOST}/tomcat/webapps/your-app"

To see everything currently deployed:

ls "${DATA_PATH_HOST}/tomcat/webapps"

Tune JVM memory (heap size)

Tomcat's startup script (catalina.sh, which the official image runs) reads the JAVA_OPTS environment variable for JVM flags like heap size. Laradock's tomcat/compose.yml doesn't set one by default, add it yourself under the tomcat service:

services:
tomcat:
environment:
- JAVA_OPTS=-Xms256m -Xmx1024m

Then apply it:

./laradock restart tomcat

View logs

Tomcat's own deployment/application logs (catalina.out, per-app logs) are written to DATA_PATH_HOST/tomcat/logs on your host, read them directly or tail them with your usual tools. For the container's own stdout/stderr (startup messages, JVM errors before logging is set up):

./laradock logs tomcat

Common issues

  • WAR file doesn't deploy. Check DATA_PATH_HOST/tomcat/logs for deployment errors, malformed WAR files or Java errors surface there, not in ./laradock logs tomcat.
  • Changing TOMCAT_VERSION doesn't take effect. Tomcat runs from a prebuilt image (no local Dockerfile to rebuild), so a plain restart after changing .env is enough: ./laradock restart tomcat.
  • Port already in use on your host. Change TOMCAT_HOST_HTTP_PORT in .env and restart: ./laradock restart tomcat.
  • Undeploying a WAR doesn't remove it. Delete both the .war file and its exploded folder from DATA_PATH_HOST/tomcat/webapps, deleting only one of the two leaves Tomcat confused about the app's state.

New to Laradock? Start at Getting Started.