How to port data-only volumes from one host to another?

前端 未结 5 1689
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 15:34

As described in the Docker documentation on Working with Volumes there is the concept of so-called data-only containers, which provide a volume that can be mounted

5条回答
  •  遥遥无期
    2020-11-29 15:52

    You can export the volume to tar and transfer to another machine. And import the data with tar on the second machine. This does not rely on implementation details of the volumes.

    # you can list shared directories of the data container
    docker inspect  | grep "/vfs/dir/"
    
    # you can export data container directory to tgz
    docker run --cidfile=id.tmp --volumes-from  ubuntu tar -cO  | gzip -c > volume.tgz
    
    # clean up: remove exited container used for export and temporary file
    docker rm `cat id.tmp` && rm -f id.tmp
    

提交回复
热议问题