Home > OS >  How to open html page in tomcat docker container
How to open html page in tomcat docker container

Time:07-02

I dont have any experience with docker or tomcat, so my question is most likely dumb. Googling didnt help in understanting what to do here so here i am. I have a task with a few steps

1)Create Dockerfile based on tomcat:9.0-alpine

2)Add html page to dockerfile and add this project to tomcat

3)Launch container and open html page in browser

Can i open the page when launching image? Something like this: FROM tomcat:9.0-alpine

RUN mkdir /usr/dock

COPY . /usr/dock/

WORKDIR /usr/dock/

CMD ["/usr/dock/index.html"]

I am on windows if it matters. Would be really grateful for any advice. Thanks

CodePudding user response:

Tomcat is specifically a server for running packaged Java applications. If you haven't already somehow placed the HTML file into a Java .war file then Tomcat probably isn't the server you need.

The easiest way to just serve a static page is with the Nginx Web server. This has a matching nginx Docker Hub image. The Dockerfile can be as little as

FROM nginx
COPY . /usr/share/nginx/html

The base image already provides a CMD so you don't need to repeat it.

You don't specifically have to use Nginx here; any server that knows how to serve static files will work. This includes Apache and the static-file-serving modules built into most Web frameworks.

  • Related