Docker-Compose Tomcat - mapping external directory

Asked

Viewed 125 times

1

I have an application running on Tomcat where when I upload an image, it saves in "portal/WEB-INF/classes/Static/img" which is a directory within my application. The problem is that when I update the application, Tomcat destroys the directory and recreates and I lose the saved images. I would like to map a directory outside my application (e.g.: /opt/img) to save these images, this is possible via Docker-Compose?

Services: Tomcat: image: Tomcat:8.5-jre8 volumes: - . /Tomcat/Webapps:/usr/local/Tomcat/webapps - . /Tomcat/Logs:/usr/local/Tomcat/logs - . /Tomcat/Webapps/portal/WEB-INF/classes/Static/img:/opt/img - . /Tomcat-users.xml:/usr/local/Tomcat/conf/Tomcat-users.xml - . /server.xml:/usr/local/Tomcat/conf/server.xml ports: - "8090:8080"

1 answer

0


No need to save outside the Docker container, this happens because you don’t have a volume for your application, try to mount a volume by following the documentation https://docs.docker.com/storage/volumes/ that will be all right, Docker is like a virtual machine, every time restarted wipes your "caches" to not consume volume of your disk, however if you feel need( that is your case) you allocate a volume to your Docker container, where the volume occupies a small part of your disk

Browser other questions tagged

You are not signed in. Login or sign up in order to post.