Moving Files to Docker Data Volume

First, I create the volume:

docker volume create --name some-volume

Then I create a file touch ~/somefile.txt

Now I want to move ~/somefile.txt

to the root of the volume some-volume

. How to do it?

+3


source to share


1 answer


You can do it with a container:

docker run --rm -v `pwd`:/source -v some-volume:/target \
  busybox cp -av /source/somefile.txt /target/somefile.txt

      

I also use tar and stdin to connect files to a remote volume via a docker client / server connection:



tar -cv -C source-dir . | \
  docker run --rm -i -v some-volume:/target busybox tar -xC /target

      

The export is similar:

docker run --rm -v some-volume:/source busybox tar -cC /source . | \
  tar -xC target-dir

      

+1


source







All Articles