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
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in DOCKER
- sqlplus myusername/mypassword@ORCL not working with Oracle on Docker
- Golang == Error: OCI runtime create failed: unable to start container process: exec: "./bin": stat ./bin: no such file or directory: unknown
- Only the first SQL script gets executed inside Docker Postgres container
- Retrieve the Dockerfile configuration from the Kubernetes and also change container Java parameter?
- Polars with Rust: Out of Memory Error when Processing Large Dataset in Docker Using Streaming
- Compiling eBPF program in Docker fails due to missing '__u64' type
- AttributeError: module 'numba' has no attribute 'generated_jit'
- Phoenix in a docker dev environment - generated code can't be saved from VSCode
- Docker on Multipass VMs: Connecting worker nodes to swarm results in rcp error
- Facing error in creating image of my react+vite project . Dockerfile error
- NextJS Docker build fails: fetch failed ECONNREFUSED
- Docker container unable to make HTTPS requests to external API
- Failed to connect to your instance after deploying mern app on aws ec2 instance when i try to access frontend
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
Related Questions in JAVA-EE-8
- Running test throws NoSuchMethodError
- Multiple applications (ear) in the same wildfly - ClassCastException
- Redirect user based on his Role in Jakarta EE web app
- WebSphere Liberty BASE transaction failure
- Migrating LDAP to local authentication elytron system in Wildfly 20.0.1 Final for JavaEE8 WebApp
- Executeing a stored procedure on PL/SQL from Eclipse give "SQL Error: 6550, SQLState: 65000"
- Error deploying Java Web application in Wildfly server 20.0.1
- javaEE8 app REST stopped working after adding keycloak-admin-client artifact
- Has javax.xml.rpc been migrated to jakarta?
- How to migrate PicketBox LdapLoginModule to Elytron?
- Java EE dinamic web projeto
- How to share value between two different classes in Java EE environment
- Using one transaction across multiple threads
- Java/Hibernate: MultiThreading - write into database
- Tomcat equivalent to Wildfly Deployment-Overlay
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?
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'