Docker Community Forums

Share and learn in the Docker community.

Moove files between the same drive but different mounting point


(Hotmykeul) #1

Hello people,

I would like to know if it’s possible to mount 2 directories on the same physical drive into 1 container who move files between the 2 mounting point, and just move files instantly, not copy and remove source files like it do for me now.

Thanks you per advance and sorry for my bad english.


(Sam) #2

well, you have no guaranty that the data will not have to be moved by the filesystem… but using the mv command is the best option…

if the data is on different physical volumes, with will still require physical movement


(Hotmykeul) #3

Yes but the two directories are on the same physical volume, if I do on my host linux mint system:

$ mount | grep /mnt
/dev/sdb1 on /mnt type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
none on /var/lib/docker/aufs/mnt/8c775b0f91f1b2eec180b330aa38d2a4e2699d08c5d80c17bd623ad5dd8299bf type aufs (rw,relatime,si=8c4b3875771dd74a,dio,dirperm1)
$
$ docker run -it -v /mnt/a:/a -v /mnt/b:/b --rm alpine /bin/ash
$docker$ mount | grep /dev/sdb1
/dev/sdb1 on /a type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
/dev/sdb1 on /b type fuseblk (rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
$docker$
$docker$ ls -l /a
total 1064960
-rwxrwxrwx 1 root root 1090519040 Feb 4 10:02 sample.txt
$docker$
$docker$ mv /a/sample.txt /b/
---->>This take a while because 1G file, it copy it to b and remove it from a

This do not have to be moved physically, this can be done logically like on my host if I do

mv /mnt/a/sample.txt /mnt/b/

This command move the file instantly

I don’t know if docker can do what I try to do, but why this is not the case?
Is it a Linux limitation or docker limitation?


(Sam) #4

this is the file system working… if all the data would still be accessible, only the file entry is moved, point to the same 1st block in the chain. has nothing to do with docker. the request comes out the root filesystem which handles it.


(Hotmykeul) #5

Can’t understand, ext4 or ntfs fs, the same thing happen in the container, but if I move file directly on my host from a to b directory, the filesystem move it instantly so why it s not possible in a container? It’s just because I have 2 different mounting points ? Docker can’t handle the move and move the file instantly? It should I think…
Can I ask this for a feature?


(Sam) #6

it works exactly the same… docker has nothing to do with it… it is a filesystem thing. issue mv… if needed the FILESYSTEM will move the data around… if not, then just the file table entry will be moved


(Hotmykeul) #7

So it is an issue, the data do not need to be moved, only the file table entry. i need to create only one volume with links to the 2 different directory, only one mounting point and it will move files instantly.

Edit:
The other problem is disk space, if I move 1G and my disk space is lower than 1G, the file can not be moved.