Appearance
Using Docker Volumes
When you run a Docker container, everything inside it is temporary. If you stop or delete the container, all files inside it are lost.
Docker volumes solve this problem — they let you save data permanently and share files between your computer and the container. In simulation work, this is especially useful for storing code, meshes, results, and logs.
What is a Docker Volume?
A volume is a special folder managed by Docker that can be:
- Shared between your system and the container
- Used by multiple containers at once
- Persisted even after the container stops
You can think of it as a bridge between your host system and Docker.
Mounting a Local Folder
The simplest way to use volumes is by mounting a local directory into the container.
For example, if your simulation files are in D:\Codes (on Windows) or ~/Codes (on macOS/Linux), you can link that folder into the container with:
bash
docker run -p 8888:8888 -v D:\Codes:/root/ -w /root/ iitrabhi/fenics_notebookHere’s what the flags mean:
-v D:\Codes:/root/→ maps your local folder to/root/inside the container-w /root/→ sets the working directory inside the container
Now any file you modify inside the container is also updated in your local system — and vice versa.
Why Volumes Matter in Simulation
In simulation workflows, volumes are crucial for:
- Keeping your simulation data safe even if containers are deleted
- Running multiple studies using the same dataset or mesh files
- Allowing real-time synchronization between your host editor (VS Code) and the Docker container
With volumes, your work stays organized and persistent — no accidental loss of results or notebooks.
Summary
- Volumes let you save data and share files between Docker and your system.
- Use
-v local_path:container_pathto mount local folders.
In short, volumes make Docker practical for daily simulation work — combining the flexibility of containers with the reliability of local storage.