Home > other >  Dockerfile, RUN git clone does not create required files/folders
Dockerfile, RUN git clone does not create required files/folders

Time:01-28

English is not my native language, so I apologize in advance for very much possible errors.

I'm new to Docker and Linux in general, and trying to learn rn. I have a task, I need to create dockerfile based upon tomcat:9.0-alpine, then in this exact file clone provided repository. Then I need to build image from this dockerfile, run container and then visit index.html in a browser, where I will see a specific page. This how my dockerfile looks like:

FROM tomcat:9.0-alpine
RUN apk update
RUN apk add git
RUN git clone https://github.com/a1qatraineeship/docker_task.git $TOMCAT_HOME/webapps/whateverApp/

When I build image from this, I see that repo was cloned in a directory, that I specified:

#7 [4/4] RUN git clone https://github.com/a1qatraineeship/docker_task.git $TOMCAT_HOME/webapps/aquaApp/
#7 sha256:72b802c3b98dad7151daeba7db257b7b1f1089dc26fb5809fee52f881e19edb5
#7 0.319 Cloning into '/webapps/whateverApp'...
#7 DONE 1.9s

But when I run container and go to http://localhost:8888/whateverApp/, I get "404 - not found". If I go to http://localhost:8888, I see Tomcat default page, so Tomcat is deffinetely working. If I bash into container and go to /webapps - I don't see a folder that I specified (whateverApp) in there.

What I'm missing? All seems to work ok, there is no errors thrown, but don't see supposedly cloned repository. In examples that I saw there was no mention about any access restrictions or whatever. Even my teacher said before, that whole dockerfile will essentially consist of 4 lines, and only thing I really need to find out is to where to clone repo for everything to work properly. But If it don't clone at all, how can I verify that I placed files into right place?

CodePudding user response:

The problem is your environment variable, is empty when the container run TOMCAT_HOME

FROM tomcat:9.0-alpine
ENV TOMCAT_HOME=/usr/local/tomcat
RUN apk update
RUN apk add git
RUN git clone https://github.com/a1qatraineeship/docker_task.git $TOMCAT_HOME/webapps/whateverApp/

and with that ENV should work, gook luck!

  •  Tags:  
  • Related