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 CLI
- Docker Compose
./laradock start tomcat
docker compose up -d 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 CLI
- Docker Compose
./laradock stop tomcat
docker compose stop tomcat
To delete the container entirely (your webapps and logs on disk are still untouched):
- Laradock CLI
- Docker Compose
./laradock remove tomcat
docker compose rm -sf tomcat
Configuration
Settings live in tomcat/defaults.env and can be overridden in your own .env:
| Variable | Default | What it does |
|---|---|---|
TOMCAT_VERSION | 9.0 | Image tag from the official tomcat Docker Hub page. |
TOMCAT_HOST_HTTP_PORT | 8080 | Host 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 CLI
- Docker Compose
./laradock restart tomcat
docker compose 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 CLI
- Docker Compose
./laradock restart tomcat
docker compose up -d 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 CLI
- Docker Compose
./laradock logs tomcat
docker compose logs --tail=100 tomcat
Common issues
- WAR file doesn't deploy. Check
DATA_PATH_HOST/tomcat/logsfor deployment errors, malformed WAR files or Java errors surface there, not in./laradock logs tomcat. - Changing
TOMCAT_VERSIONdoesn't take effect. Tomcat runs from a prebuilt image (no local Dockerfile to rebuild), so a plain restart after changing.envis enough:./laradock restart tomcat. - Port already in use on your host. Change
TOMCAT_HOST_HTTP_PORTin.envand restart:./laradock restart tomcat. - Undeploying a WAR doesn't remove it. Delete both the
.warfile and its exploded folder fromDATA_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.