< Docker 
 
 
      Dockerfile
# Configures a Tomcat web server and copies the current folder content
# to use as webapps/ROOT.
# Use the following commands to build and run the server.
#   docker build -t tomcat-server .
#   docker run -d -p 8080:8080 --name=tomcat-server tomcat-server
# Then open a web browser and connect to http://localhost:8080 .
# References:
#   https://hub.docker.com/_/tomcat
#   https://cs.brynmawr.edu/~dkumar/JSP/
FROM tomcat:alpine
WORKDIR /usr/local/tomcat/webapps/ROOT
COPY . .
EXPOSE 8080
CMD ["catalina.sh", "run"]
index.jsp
<%
// Displays "Hello world!"
//
// References:
//   https://www.javatpoint.com/jsp-tutorial
out.print("Hello world!");
%>
Try It
Online Free
- Use Play with Docker. Create an account and/or log in.
- Start an interactive session and add a new instance.
- In the terminal window, enter the following commands:
- touch Dockerfile
- touch index.jsp
 
- Use the Editorbutton to edit both files and save the contents above into each respective file.
- Run the following commands:
- docker build -t tomcat-server .
- docker run -d -p 8080:8080 --name=tomcat-server tomcat-server
 
- In the top window, select the 8080button to connect to the running server.
On Your Own System
- Install Docker Desktop or the Docker Engine.
- Save the files above into a new Docker Flaskfolder:- Dockerfile
- index.jsp
 
- At a command prompt, change to the Docker Flaskfolder and then run the following commands:- docker build -t tomcat-server .
- docker run -d -p 8080:8080 --name=tomcat-server tomcat-server
 
- Open a web browser to connect to the running server:
See Also
    This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.