How to fix the HTTP Status 404 - Not Found Error for the Docker Tomcat image?
While trying to pull Tomcat image from Docker Hub to install Tomcat server on Amazon EC2 Linux virtual machine by executing the below commands in the terminal:
docker pull tomcatdocker run --name tomcat-server -p 8080:8080 tomcat:latest
And when you open the browser by visiting http://container-ip:8080, you might have noticed the HTTP Status 404 – Not Found.
HTTP Status 404 – Not Found
Type Status Report
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
You might have started thinking that you have done some mistakes while installing the Docker image. If you are thinking in those lines, then you are wrong. This is no error and it was designed to behave like this due to security concerns raised by the Docker community. You can find this information on security on the Tomcat image official documentation in DockerHub
The information which is provided on Tomcat image official documentation in DockerHub isn't helpful for the people who have the beginner level knowledge of Docker.
Based on the community request, Webapps folder is moved to the webapps.dist folder, which means webapps folder is empty and there are no files to serve on the browser. That is when you saw the error message The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
To re-enable the webapps, we need to move the files from webapps.dist to webapps. Here are the steps to run to make sure that the tomcat server is up and running without any issues. Please run the below commands step by step:
docker pull tomcat:latest
docker run -d --name mytomcat -p 8080:8080 tomcat:latest
docker exec -it mytomcat /bin/bash
mv webapps webapps2
mv webapps.dist/ webapps
Hope this information helps!