Where to find the tomcat folder in the docker image
Asked Answered
B

1

6

I'm using ubuntu and I have installed Docker and started my first tutorial using Tomcat.

I made a docker file named Dockerfile that contains

FROM tomcat:7-jre7
MAINTAINER "Craig Trim <[email protected]>"

Then I build the image using

sudo docker build -t craig/tomcat .

and finally I started Tomcat:

sudo docker run -p 8080:8080 craig/tomcat

Now in the console, it shows that Tomcat is installed somewhere in /usr/local/tomcat

4-Nov-2016 10:36:57.031 INFO [localhost-startStop-1]   org.apache.catalina.startup.HostConfig.deployDirectory Deploying web     application directory /usr/local/tomcat/webapps/host-manager

But when I go there I did not find the folder tomcat. Where to find that folder, so that I can configure some files?

Burkhard answered 4/11, 2016 at 10:59 Comment(2)
What is the output of docker logs <container id>?Oleneolenka
Were you looking for the directory inside the container or on the host?Program
K
16

I ran the apache container in the background (-d):

docker run -d -p 8080:8080 tomcat:7-jre7

I checked if the container was running

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
c2ca0d66536c        tomcat:7-jre7       "catalina.sh run"   9 minutes ago       Up 9 minutes        0.0.0.0:8080->8080/tcp   focused_bell

I went 'inside' the container using its container ID:

docker exec -it c2ca0d66536c bash
root@c2ca0d66536c:/usr/local/tomcat#

Now I'm able to go inside the application directory /usr/local/tomcat/webapps/host-manager :

root@c2ca0d66536c:/usr/local/tomcat# cd webapps/host-manager/
root@c2ca0d66536c:/usr/local/tomcat/webapps/host-manager# ls
META-INF  WEB-INF  images  index.jsp  manager.xml

I hope this was your question? Because it was not very clear for me. If it wasn't I'll delete or edit the answer. I think your 'problem' was the fact you're running the container in the foreground.

Knapsack answered 4/11, 2016 at 13:11 Comment(5)
just small question i want to see that in the UI(i mean in the ubuntu explorer ) how can i do that?Burkhard
You mapped the port of your apache container (8080) on 8080 of the host. So normally you should see the main page of apache on localhost:8080 or IP:8080 (where IP is the public ip of your ubuntu?). Don't know if you're using a real server or a local vm. When you have a browser inside your ubuntu explorer you can just visit localhost:8080Knapsack
no i wan to see the tomcat directory that i saw it in the bash in ubuntu explorer (tomcat contains webapp,include,conf,lib...)Burkhard
You can only see that from inside your container. If you want to put something in that folder you have to write a COPY statement in your dockerfile to copy your apps in that folder in your container, or you can mount your applications inside that folder.Knapsack
Thanks - exactly what i was looking forSpirant

© 2022 - 2024 — McMap. All rights reserved.