babs84
babs84

Reputation: 451

Copy files to the tomcat webapps folder in Docker container using Docker-compose

I have a scenario like i had to copy couple of configuration files to the tomcat webapps folder which exists inside the docker container. Here is my dockerfile which i use

FROM tomcat:7.0.82-jre8
RUN apt-get update && apt-get -y upgrade
WORKDIR /usr/local/tomcat
COPY /app.war /usr/local/tomcat/webapps/app.war
RUN apt-get update && apt-get install -y dos2unix
EXPOSE 8080
COPY tomcat-users.xml /usr/local/tomcat/conf/

Once we run the docker, it actually does the following

  1. It actually copy app.war to the tomcat webapps folder and extracts to an folder named "app"
  2. Docker will try to start the tomcat server.

I want to copy my configuration file to the extracted war file which is inside the tomcat webapps folder. Here is the location of the property look like tomcat_home/webapps/app/conf/services.properties before starting the tomcat server

I am having a challenge of copying this property file to the corresponding folder before starting the tomcat caontainer.

I am not sure how to do this using docker-compose. Whether is this really possible in docker-compose.yml or using dockerfile ? Any answers would be appreciable.

Upvotes: 1

Views: 4502

Answers (2)

Pratheesh M
Pratheesh M

Reputation: 1078

Yes it is possible. Either you can use volume: inside services part of docker-compose.yaml file or you can specify copy command inside docker file. syntax: copy source destination in docker file. Or
volumes: <folder/path/in/host> : <folder/path/in/container> in docker-compose

Upvotes: 1

Vignajeth
Vignajeth

Reputation: 708

you cannot copy the files using docker-compose.yml,but you can use the COPY command in Dockerfile to put the file into the container, maybe you are confused the path /app/conf/services.properties is not a directory that is why the copy didn't happen and the Docker didn't throw error the other way is you can mount a volume which can be done using the docker-compose.yml

Upvotes: 0

Related Questions