How to change the Tomcat port from 8080 to 80 in a Dockerfile


I am using tomcat:alpine as my base image in my Dockerfile but I want to run Tomcat on port 80 not 8080.


Add the following line to your Dockerfile:

RUN value=`cat conf/server.xml` && echo "${value//8080/80}" >| conf/server.xml


I am sure many of you are wondering why I did not use –p 80:8080 in my Docker run command. Because I am not issuing a run command. I am using the new Azure Container Instances that I spun up using an Azure Resource Manager template. The instance is running in a Container Group and they do not support port mapping. Therefore, I had to change the port Tomcat exposes.

Comments (1) -

  • this has not worked for me.

    Using this was successfull:
    RUN sed -i 's/port="8080"/port="80"/' /usr/local/tomcat/conf/server.xml

Add comment