I'm new to docker and I have been trying to run a container that deploys my Java web app on a tomcat image. The problem is my app has to read and write into a file that it accesses on my machine and clearly when the app's .war file is deployed on tomcat as a docker container it cannot find the file since the file is no longer recognized. I was trying to see how I can fix that and came across docker volumes. I have the idea of storing my file in a volume and then having my application retrieve data from it but I cannot find a way to do it. I've been looking for a way to see how I can modify the path in my app to point to a file that's in a docker volume but I cannot find anything. Perhaps I missed something as I've been trying to learn more about docker volumes? Please point out the right way to do this or maybe provide a helpful link that shows how something similar can be done, or if I am completely wrong about this approach please let me know.
Related Questions in JAVA
- Can MVC.NET prevent SQL-injection at razor or controller level?
- SQL server not returning all rows
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Creating a parametrized field name for a SELECT clause
- Combine two rows based on common ID
- Column displays each count
- Slick query for one to optional one (zero or one) relationship
- Aggregate and count in PostgreSQL
- MAX and GROUP BY - SQL
- SQL statement for a tricky 2 table query
Related Questions in DOCKER
- Can MVC.NET prevent SQL-injection at razor or controller level?
- SQL server not returning all rows
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Creating a parametrized field name for a SELECT clause
- Combine two rows based on common ID
- Column displays each count
- Slick query for one to optional one (zero or one) relationship
- Aggregate and count in PostgreSQL
- MAX and GROUP BY - SQL
- SQL statement for a tricky 2 table query
Related Questions in JAVA-EE-8
- Can MVC.NET prevent SQL-injection at razor or controller level?
- SQL server not returning all rows
- When dealing with databases, does adding a different table when we can use a simple hash a good thing?
- Creating a parametrized field name for a SELECT clause
- Combine two rows based on common ID
- Column displays each count
- Slick query for one to optional one (zero or one) relationship
- Aggregate and count in PostgreSQL
- MAX and GROUP BY - SQL
- SQL statement for a tricky 2 table query
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Here is the official documentation on volumes and mounts https://docs.docker.com/storage/volumes/
This is an example on how you would mount a mysql container to your drive, this is a good idea to keep the data even when the container is deleted. Look at the point "Where to store data"
https://hub.docker.com/_/mysql/
This is a very short version for a docker compose to mount a folder inside the container to an external folder
*This are only 2 lines from a complete docker-compose file but should demonstrate how to mount a data.
The folder left of the ':' Is the folder where your data is located on your drive the folder left of the ':' to which folder inside the container this refers.
When you are looking for a file in folder './datafolder' you should mount your the folder ./ inside your container to the folder on your drive which contains 'datafolder'