Installing Tomcat Web Server through Docker File For Windows Container

Installing Tomcat Web Server through Docker File For Windows Container

Installing Tomcat Web Server through Docker File For Windows Container

In this blog, we will show you installing tomcat web server through docker file for Windows container

 

REQUIREMENTS

  • Windows container host with Docker service installed.
  • Base windows server core image.
  • JAVA & TOMCAT Installation files.

 

DOWNLOAD JRE SETUP FILE

image

 

  • Click on Agree and Start Free Download to download the file.

image

DOWNLOAD JDK SETUP FILE

 

image

 

  • Click on jdk8u131_windows-x64.exe link to download the JDK file.

image

DOWNLOAD AND CUSTOMIZE TOMCAT

image

  • Click on 64-bit Windows zip link to download the 64-bit version of tomcat.

image

  • Extract the downloaded ZIP file apache-tomcat-9.0.0.M21-windows-x64.zip to an folder named tomcat

image

 

  • Go to tomcat\conf\ folder and open web.xml file in notepad.

image

 

image

 

  • To enable the directory listing, change the “listings” value from false to true

image

 

  • Go to tomcat\conf\ folder and open server.xml file in notepad.

image

image

  • To change the TCP Port, locate the word connector port and change the port number for your environment.

image

 

Note: In this demo, we are using the default port for tomcat is 8080

 

  • Go to tomcat\conf\ folder and open context.xml file in notepad.

image

 

image

 

  • To Enable automatic reload after code changes, add <Context reloadable=”true”> in the context.xml file.

image

 

PREPARING ENVIRONMENT FOR BUILDING IMAGE

  • Create a folder named Java under c:\ drive using below command.

New-Item -type Directory -name java -path c:

image

 

  • Create a subfolder named setup under C:\java using below command

New-Item -Type Directory -Name setup -path c:\java\

image

 

  • Copy the download JRE, JDK & tomcat files to C:\java\setup folder.

image

 

  • Create a new file named jre.cfg in C:\java\setup folder.

image

 

  • Add the below content on jre.cfg file and save it.

INSTALL_SILENT=Enable
SPONSORS=Disable
NOSTARTMENU=Enable
REBOOT=Disable
EULA=Disable
AUTO_UPDATE=Disable
STATIC=Enable

  • Create a new file named jre.cmd and add the below content and save it.

pushd %~dp0
start /wait jre-8u131-windows-x64.exe INSTALLCFG=%~dp0jre.cfg

image

 

  • Create a new file named jdk.cmd and paste the below content and save it.

pushd %~dp0
start /wait jdk-8u131-windows-x64.exe INSTALLCFG=%~dp0jre.cfg

image

 

 

  • Create a new file named Environmentvariable.ps1 under C:\java\setup folder and add the below content and save it.

[Environment]::SetEnvironmentVariable(“JRE_HOME”,”C:/Program Files/Java/jre1.8.0_131″)
[Environment]::SetEnvironmentVariable(“JAVA_HOME”,”C:/Program Files/Java/jdk1.8.0_131″)

image

 

  • Create a new file named tomcatservice.bat and paste the below content and save it.

cd\
cd .\tomcat\bin\
.\service.bat install

image

 

  • The overall file structure of setup folder has shown below.

image

 

CREATING DOCKER FILE FOR BUILDING IMAGE

  • Create a new file named dockerfile under C:\java folder using below command.

image

 

  • Open the dockerfile in notepad and paste the below contents and save it.

# THIS DOCKER FILE WAS DEVELOPED BY ASSISTANZ NETWORKS

# SPECIFY THE CONTAINER IMAGE
FROM microsoft/windowsservercore

# COPY THE APACHE INSTALLATION FILES INTO THE CONTAINER
ADD ./setup c:/source

RUN powershell.exe -command \

# INSTALLING JAVA JRE
./source/jre.cmd; \

# INSTALLING JAVA JDK
./source/jdk.cmd; \

# COPYING CUSTOMIZE TOMCAT FILES TO C drive
Copy-Item c:/source/tomcat -Destination c:/tomcat -Recurse; \

# SETTING UP ENVIRONMENT PATH VARIABLES FOR JRE & JDK FOLDERS
./source/Environmentvariable.ps1; \

# Installing Tomcat service
cmd.exe /c c:/source/tomcatservice.bat; \

# SET TOMCAT SERVICE TO RUN UNDER LOCAL SYSTEM ACCOUNT
sc.exe config tomcat9 obj=LocalSystem start=auto; \

# REMOVE TOMCAT SETUP FILES FROM SOURCE DIRECTORY
cmd.exe /c rd /S /Q c:\source

image

 

BUILDING THE IMAGE

 

  • Open the PowerShell window and execute the below command to build the image.

docker build –t tomcat c:\java

image

It will take few minutes to complete the building process.

 

  • The build completed successfully as shown below.

image

 

VERIFYING THE INSTALLATION

  • Verify the images using docker images command.

image

  • Launch a new container using below command.

docker run -it -p 80:8080 tomcat powershell

image

 

  • Once the container has been created verify the tomcat service status using below command.

Get-Service tomcat9

image

 

  • Browse the container host IP (192.168.232.80) to view the default homepage.

image

 

VIDEO

Thanks for reading this blog. We hope it was useful for you to learn how to install Tomcat web server in windows container.

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn
More Interested Related Posts
zfs pool usage

ZFS Pool and Dataset Usage

ZFS Pool and Dataset Usage   I am back with another blog to provide the useful script to the Freebsd users to determine the zpool

Assistanz Networks

Installing Zabbix Agent in FreeBSD 12.0

Zabbix Agent Installation and Configuration Guide on FreeBSD 12.0   Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual

DirectAdmin Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk
$ 99 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • NDA & SLA
  • SLA Review Meetings
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation
  •  

Platinum Support

24/7 Proactive Support
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Support

$ 30 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response Time
  • 4 Hours Resolution time for the Possible Issues
  • Security and Performance Optimization
  • React to Customers queries
  • Simple SignUp Process
  • Instant Account Activation
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support