简体   繁体   中英

Persist a file path of a docker mapped volume on host into database

What I have: A spring boot application running as/inside a docker container. This application gives an opportunity of uploading files to a directory inside the docker container. I also have specified a volume mapping on the server/host which points to this directory.

What I need: Persist the path of the host directory (docker volume?), which points to the directory inside the docker container, into database in order to refer to it later. How can I do this?

IIUC there's no intrinsic way to determine the volume mapping from within the container.

You could achieve this by passing an environment variable to your process and having confidence its value is correct:

V=/path/to/src
docker run .... \
--env=V=${V} \
--volume=${V}/path/to/dst \
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM