Search code examples
linuxdockermounttransferdocker-volume

How to unpack a file on one docker volume into another?


I have two questions:

  1. What command can I use, to move a file into another docker volume?
  2. What command can I use, to extract a file into another volume?

I have Docker running on a VPS with 160GB Disk space. I downloaded a snapshot .tar file on that VPS and the next step would be to unpack it. However, because the unpacked file is 88GB, I added an additional volume with 100GB to my droplet.

My plan is, to move that .tar file to the 100GB volume. And then unpack it back into the main 160 volume.

This would be the code to unpack the file: cd /tmp

an then: sudo tar xvC /var/lib/docker/volumes/NAME_OF_YOUR_VOLUME/_data/data/tomo/ -f 20190617.tar

But I am a newbie and I don't understand that command and don't know how it works, when you have two volumes.


Solution

  • This is how I solved it.

    1. find the new volume: fdisk -l
    2. create a new directory and then mount the volume on it: sudo mount /dev/something /new/dir
    3. extract the .tar on that mounted directory: sudo tar xvC /new/dir -f 20190617.tar
      1. move it to the docker volume(after making room by deleting the .tar): cp -R /var/lib/docker/volumes/...