Docker Community Forums

Share and learn in the Docker community.

Docker Volume - How to specify source path?

docker

(Ellery Leung) #1

Hi all

I am currently reading https://docs.docker.com/storage/volumes/ which talks about docker volume.

And my situation is: I have a rasa_nlu container which has a /app directory inside, and my host has an empty directory called /root/rasa_nlu

My goal is to map/bind/connect /root/rasa_nlu in my host machine to /app in my rasa NLU container.

So I first run docker volume create rasa_nlu_vol

And I run

docker run -d -p 5001:5000 --mount type=volume,source=rasa_nlu_vol,target=/app --name rasa_nlu_test rasa/rasa_nlu:latest

While I can successfully run the container, the data in container is now in /var/lib/docker/volumes/rasa_nlu_vol/_data, which I don’t want to.

Yes I know I can simply use ln -s to solve this problem, but I want a much clever solution, which is to specific both the source and target absolute path directory.

Can it be done?

Thank you.

By the way, below are my suggestion:

I don’t know why I need to run docker volume create <some_name> before running docker run, can it be simplified by automatically create a volume for us when we use --mount type=volume,name=my_fancy_name_about_my_vol,src=/another_fancy/my_source,target=/final_fancy/my_dst? It is much simpler!

Thank you.