This docker image uses official tomcat (https://hub.docker.com/_/tomcat/) as base image and add the nginx (https://hub.docker.com/_/nginx/) for :-
- serving static files
- do basic http headers eg. cache / expires
- redirecting
- proxy to tomcat
To start a container with nginx (daemon), just simply run the container without any argument.
sudo docker run -d wongnai/tomcat-nginx:8.5.5-jre8
After starting the container, you should be able to make a request to both nginx (port 80) and tomcat (port 8080).
Just pass any argument when running a new container so that the container is not start nginx daemon.
sudo docker run -d wongnai/tomcat-nginx:8.5.5-jre8 no-nginx
Basically this image should be used as base image.
The tomcat and nginx configuration directories respectively are at :-
- /usr/local/tomcat/
- /etc/nginx
The entry point of the image should look like this:-
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["with-nginx"]
You can put warm up script at path /usr/local/tomcat/bin/warmup.sh
,
So it will run after start tomcat server. After warm up script finished, it will start nginx then.