Move from docker volume to bind mount

Currently reading
Move from docker volume to bind mount

4,152
1,428
NAS
DS4l8play, DS202j, DS3623xs+, DSM 8.025847-𝘣𝘦𝘵𝘢
I have a docker container which has a /config folder set up as a docker volume. I want to relocate this to a bind mount... for example to
/volume1/docker/calibre/config'
So from this
Code:
    volume:
      - config:/app/config
volumes:
  config:
to this
Code:
    volume:
      - /volume1/docker/calibre/config:/app/config
I've managed to migrate other containers from bind mounts to docker volumes, without great difficult, but reversing the process has not been successful. Generally I rsync the content (-axPS) and then update the compose file, but container recreation hasn't restored my working setup.

Are there "magic" permissions that makes copying from the docker volume to a bind mount that I own an issue? Or other? Thank you.
 
I saw your post in the Docker forum, so I know that you tried to use docker-root-data/volumes/config/_data as source.

Instead, you might want to use an ephemeral container that mounts the volume as source and the bind as target and perform the operation inside an ephemeral container.

After stopping every container that uses the config volume, something like this should do the trick:

Code:
docker run -it --rm -v config:/source -v /volume1/docker/calibre/config:/target buddy/rsync rsync -axvPS /source /target

I don't use rsync, so the command after the image is what I came up after seeing your post in the Docker forum and reading the output of rsync --help.

Though, what exactly is not working?
 
Though, what exactly is not working?
Primarily I am concerned with easily backing up the metadata for my calibre library that resides under /config. I have the same issue with Plex, as I used docker volumes for its /config when setting it up. For both containers I use bind mounts for the actual media content.

I'm grateful for your post and I will test it out on some minor containers initially to ensure I understand, and I'm able to do it without destruction of the persistent /config volumes..
 
docker run -it --rm -v config:/source -v /volume1/docker/calibre/config:/target buddy/rsync rsync -axvPS /source /target
I ran this as root (sudo -i) from the directory housing the docker-compose file, and the only effect is that the empty directory "source" is created below the "config" target. Specifically /volume1/docker/calibre/config/compose

I then replaced the rsync command with cp -r and the same occurred. What am I overlooking? Thanks!
 
If the source folder is empty, the volume name probably is not config. If it's created from a compose project, the volume name is high likely prefixed with the project name (which defaults to the directory name where the compose file is located).

You should find the volume name in the output of docker volume ls.
 
That was it... the volume name was <container name>_config. I thought I could use the name defined in the compose file.

I added a slash to the rsync destination to avoid the creation of the “source” directory in the target... rsync -axvPS /source/ /target

Thanks so much, I would have never figured this out. The closest examples I tested, involved creating tar backups of the docker volumes.

After the docker recent release trashed Portainer, and my “solution” led to “Error: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network”, I'm having to burrow deeper into docker than simply docker conpose up -d 🍪
 
A rough way could be to stop the container and add /volume1/docker/calibre... as a second, temporary mount point, e.g. /temp. Then just copy the the folders and files from /config to /temp, observing how you've structured it. In the container's Terminal session you can find the command syntax using cp --help.

Once everything is copied across you stop the container and make /volume1/docker/calibre... the mount point for /config. Or whatever it needs to be.

From within DSM command line I suspect you could also use tar cvf to make a tarball archive of the current config folder. Then use tar xvf to expand it at the new /volume1/docker/calibre folder. I seem to recall it preserves the permissions.
 
A rough way could be
Thanks... I tried something similar with rsync. The docker volume lived in volumeX/@docker/volumes/calibre/calibre_config, and copying that to my shared folder directory didn't result in a fully recognized container (after tidying up the compose file and launching a new container). I'm unsure why, but the volume mount method above worked well for the container I trialed.
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Similar threads

For the heck of it, I just checked again in docker container, and it announced an update was available. I...
Replies
4
Views
491
  • Question
Do realize, that enabling any user to run docker containers is largely the same as giving that user full...
Replies
6
Views
1,120
Hello, I already have it configured perfectly with wireguard. I was looking at the Gluetun configuration...
Replies
4
Views
769
I can’t find any option to restore just the settings. 1710356648 Phew, managed to fix it. Within the...
Replies
4
Views
596
Good to hear. Deluge has not been updated for almost two years now as an app, nevertheless. But it gives...
Replies
12
Views
1,299
  • Question
Open an issue on that GitHub page. The developers will be glad to assist. OP has posted two threads on...
Replies
5
Views
1,258
I'm happy with email notifications but in v0.3.3 of dockcheck the author added apprise notifications...
Replies
4
Views
1,484

Welcome to SynoForum.com!

SynoForum.com is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!

Trending threads

Back
Top