Ravindu Nirmal Fernando
Ravindu Nirmal Fernando

Reputation: 4822

How to remove ROOT folder from a Docker Container running Tomcat base image

I want to know whether if there is any method to remove the ROOT folder within the tomcat /webapps folder after its being deployed by a Docker image.

The reason that I want to achieve this is that I want to run my .war file as the root. I have already renamed my war file as ROOT.war. But when I run my Docker image with the tomcat base image, a ROOT folder is also created by default within the container's tomcat/webapps folder which doesn't allow me to access my ROOT.war file as the root.

My Dockerfile

# Pull base image
FROM tomcat:8.0.30-jre7

# Copy to images tomcat path
COPY /ROOT.war /usr/local/tomcat/webapps/

Upvotes: 6

Views: 5188

Answers (1)

Rob Lockwood-Blake
Rob Lockwood-Blake

Reputation: 5056

Sure. You can just delete the already existing ROOT folder as part of your Dockerfile:

# Pull base image
FROM tomcat:8.0.30-jre7

# Delete existing ROOT folder
RUN rm -rf /usr/local/tomcat/webapps/ROOT

# Copy to images tomcat path
COPY ROOT.war /usr/local/tomcat/webapps/

Upvotes: 13

Related Questions