2019年7月4日 星期四

docker jsp server

Ref: https://gist.github.com/hallazzang/c346e544b1c6fce8f304fdd5b2295fb6

ASUS X450J @ Windows 10 x64
docker

1. 檔案架構
yourproject/
    Dockerfile
    webapp/
        WEB-INF/
          classes/
          lib/
          web.xml
        index.jsp

yourproject/webapp/WEB-INF/web.xml

<web-app>
</web-app>

yourproject/webapp/index.jsp

<!doctype html>
<h1>It works!</h1>
<%
  for (int i = 0; i < 5; ++i) {
      out.println("<p>Hello, world!</p>");
  }
%>

Dockerfile

FROM tomcat:9.0.1-jre8-alpine
ADD ./webapp /usr/local/tomcat/webapps/webapp
CMD ["catalina.sh", "run"]
$ docker build -t mywebapp .

$ docker run --rm -it -p 8888:8080 mywebapp