I have a docker-compose.yml
configuration. In one of the containers there is a Tomcat server and it has some default .war
file deployed in webapps
directory.
I want to have an ability to pass (override) the war
archive to be deployed by some which resides on the host machine. I think the best would be to have ability somehow switch / override starting docker-compose
: as a default, I want to run the webapp (war
file) which is inside the container, but I want to have a possibility to mount a directory from my host (for example during development / debugging) if need be.
Currently, I have the following line in my docker-compose.yml
, which is commented out if I need the default.
volumes:
# By default, there is the latest version of the application already present in the container
# If you want to provider the container with your own .war file, uncomment the following line
# - ./application/webapps:/usr/local/tomcat/webapps
Is there a better way how to achieve that?
Instead of (not) mounting a volume commenting out that line, I would use https://docs.docker.com/compose/extends/#example-use-case to run a service extension that specifies a volume.
I do this to tackle two different problems: