I'm new to docker so sorry if I miss something obvious
My plan for the Dockerfile.
I've managed to do this by running these commands manually.
docker run -it --rm -p 8888:8080 tomcat:8.0
Then manually doing the wget
's and renaming, although I would like this to all be done in the docker file.
This is what I've managed to do so far.
FROM tomcat:7.0
RUN /bin/bash -c "cd /usr/local/tomcat/webapps"
RUN /bin/bash -c "wget -O files.zip https://***"
RUN /bin/bash -c "unzip files.zip"
RUN /bin/bash -c "rm -r ROOT"
RUN /bin/bash -c "wget -O ROOT.war https://***"
Although I am not sure how to run the docker line from earlier
docker run -it --rm -p 8888:8080 tomcat:8.0
I've taken that line from the official Tomcat online here. I noticed they mentioned this Run the default Tomcat server (CMD ["catalina.sh", "run"]):
but I have no idea how to implement this.
What a Dockerfile does, is create an image not a container.
When you do docker build -t <tagname> .
and will see the result (tagged) if you run docker images
.
You can then run that image to create a container.
You can also specify a CMD
to run (by default) in the Dockerfile
. That would be (I think)
CMD [ "catalina.sh", "run" ]
So:
docker build -t my_tomcat_app .
docker run -d -p 8888:8080 --name my_tomcat_container my_tomcat_app
This will create a container from your image, and run whatever the CMD
said. You can poke around inside it with docker exec
docker exec -it my_tomcat_container bash
But it'll stay running (because of the -d
flag) and show up in docker ps
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With