if a want edit file in some volumes, from host ubuntu, can i write directly in
/var/lib/docker/volumes/[ volume id ]/_data ?
My general take is that you should never ever directly touch anything inside
/var/lib/docker, and correspondingly, the default Docker-managed volumes can’t be directly accessed from the host. You can inject a host directory into a container using
-v or create a bind-mount named volume and those might be easier to manage.
(I think, yes, that works, but it’s hard to manage.)
Does it seem so much easier?
what problems could there be?
- Finding the volume ID
- Having to be root
- Generic problems with concurrent file modification
- Doesn’t work with a non-default storage driver (NFS, Convoy, Digital Ocean, …)
- Won’t work if Docker changes the filesystem layout or implementation here
/var/lib/dockercontains no user-serviceable parts, warranty void if opened
interesting, thank you
but to add a volume to a docker started, do I have to stop the “production”, destroy the docker and recreate it?
Yes, this is one of a handful of settings that you need to stop, delete, and restart a container to change. The underlying image is another big important one. (If you update your application, after you rebuild its image, you need to recreate the container on the new image.)
To get back to your original question, this also means that it’s important that you set up your containers so that any data that needs to be persisted is in a host directory or a volume and not in the container itself.
thanks for the help, it was very useful, good evening David