Docker Community Forums

Share and learn in the Docker community.

Using a regex as volume source


(Philippe) #1

Hey all,

I am using docker compose to dockerize our tests.
I need to copy a war-file to the tomcat webapps folder in the container.
The war-file has a version number.

I tried the following:

volumes:
    - ../app/target/*.war:/usr/local/tomcat/webapps/app.war

But the war-file does not get detected on the host.
Instead, an empty folder is created under webapps.

If I do not specify the war-file and copy everything from the target folder, Tomcat creates a context path using the version number like /app-2.16.0 but it needs to be just /app

Any ideas on how I can accomplish this?
Thank you in advance.
Regards


(Metin Y.) #2

if target is the output folder of a your build, you don’t want to bind a specific file (think about it as binding the handle of that specific file to a file in the container) from the host to the container. Been there, done that -> due to the bind, the war file is still in use… which made follow up builds fail.

Instead you can map …/app/target/ into /usr/local/tomcat/webapps/ (think about it as binding the handle of the folder to a folder inside the container).

Wildfly, for instance, allows to set the context path in WEB-INF/jboss-web.xml. Regardless of the filename, the specified context path will be used. There must be something comparible for tomcat.