i’m trying to override the context.xml file on a docker container using volume mapping feature on docker-compose file
volumes:
- /tmp/project/context.xml /opt/apache-tomcat/webapps/project/METAINF/context.xml
the problem is that METAINF directory contains other files and when mounting the volumes docker deletes the files keeping only the context.xml file
is there a way to map only the context.xml file without deleting the other files ?
PS: docker-compose version is 2.1
2
Answers
I don't see why it's different for me.
my docker-compose file:
this is when i try to mount the context.xml file
when i'm not mounting the volume
It is absolutely possible to mount a single file without replacing the directory. What you are trying should Just Work. You haven’t provided enough information for us to reproduce your specific problem, but here’s an example:
I don’t have a tomcat application handy, so let’s assume I want to replace the file
/etc/issue
with a local file.I would structure my
docker-compose.yaml
like this:Assuming that my local
issue
file contains:Then after brining up this environment…
…the
/etc
directory still contains all the expected files:But
/etc/issue
has my custom content: