Mount new volume on existing running container

A pen was invented to write something mainly on paper. You can use it to write on your clothes or even on your hand if you really have to write a phone number and you don’t have a paper. Not something you would do every day but it would work. On the other hand, you could use a pen to eat your salad, but it would be problematic when the ink goes into your salad. So yes, people invent things for a purpose and you can follow the guide or ignore it. You have the right and you can be creative, but you will have a lot of problem, so instead of forcing the waiter to tell you how you can eat with your favorite pen, you should ask the waiter what you should use to eat it.

If you don’t know the tools you are using nobody can help you, except tell you what the right tool is for your goals.

We could write a complete book for everyone personally to explain why and what they re doing wrong and how Docker should be used, but that would be pretty hard so what we do is share some ideas, point to the right direction. You can take it and ask back to try to understand or fight it and feel we are trying to tell you what to do. No, we are trying to make your task easier.

You want to create multiple volumes to mount them into a container, most likely into the same base directory. But you don’t even need multiple volumes. Just a single bind mounted folder when you create the container and you can create as many folders inside as you want and any time. Even when the container is already running.

1 Like

You are absolutely right… and everyone is right now… maybe I am using something that is not yet (today) ready for what I want… who would have thought, that latex was invented to be used as gloves, in the end they could also be used as condoms…

Sometimes we create products and tools for a particular purpose and someone finds a second, equally important purpose or a way to extend their functionality.

I’ll try the idea of ​​a single volume.
But I am clear that the problem with this is that I could no longer use any directory on the host operating system as an anchor for the data and I would be limited to only using the directory of the main volume already previously declared.

This command allows me to create a volume using any directory on the Host OS… and not depend on the status of the container o volumes.

docker volume create --driver local --opt type=none --opt device=C:\test-server --opt o=bind new-volumen-name

This path would only be feasible for me if this volume can be added/injected to the running Container, if this cannot be done… another way must be found… like commit or Devilbox

Clearly we don’t understand your ideas for using volumes, so please, if you feel there is a feature missing that we still don’t understand, open a ticket in the roadmap on GitHub where the developers can see it

If you can describe your use case there is a chance it will be implemented some day. We have never needed to add volumes after a container was created just to add more data, but if you have that use case, the roadmap is where you can ask for it.

ok let’s see if they attend to it at some point…
Improvement in the integration of docker and/or docker-compose real-time volumes.

@rimelek Do you think this is very complex and difficult to support?

I don’t know, but I don’t think complication will be the issue here. Unless you can make the developers understand why you think it is not possible to recreate the container with the new volumes by editing a compose file and running docker compose up -d or just bind mounting a folder which you can edit on the host to add more content, it is not likely they would implement it. As I said we have never needed it and I don’t know anyone who needed. It is not just about Docker. There is no container technology I know (besides the modified Docker on Synology) that has this feature. Containers are always recreated or we use bind mounted folders when otherwise it would require too many restarts / recreating containers.

So, if you found a use case that is good enough to implement a feature that allows you to add volumes without recreating the container, you could start big change in the container runtimes in general.

you can try this like :-
docker run -it -v test:/var/www/html/your-dir --name