How to copy docker volume from one machine to another?

I have created a docker volume for postgres on my local machine.

docker create volume postgres-data

Then I used this volume and run a docker.

  • Connecting to Oracle XE running on Docker
  • Docker: Why is /etc/resolv.conf unreadable? Breaks DNS [closed]
  • Can I export a container with data and everything to spawn a complete copy on another computer?
  • Dockerfiles or images in docker hub?
  • Creating a new PostgreSQL user in Dockerfile
  • Apache Mesos's Docker Containerizer
  • docker run -it -v postgres-data:/var/lib/postgresql/9.6/main postgres

    After that I did some database operations which got stored automatically in postgres-data. Now I want to copy that volume from my local machine to another remote machine. How to do the same.

    Note – Database size is very large

  • How to port data-only volumes from one host to another?
  • Xt error: Can't open display, if using default DISPLAY
  • Unable to compile cpp via docker in Travis-CI: /usr/bin/ld: cannot open output file a.out: Permission denied
  • How to set up Docker file to install Calabash-android?
  • What is the location of redis.conf in official docker image?
  • Docker Compose - Remove dangling service
  • One Solution collect form web for “How to copy docker volume from one machine to another?”

    If the second machine has SSH enabled you can use an Alpine container on the first machine to map the volume, bundle it up and send it to the second machine.

    That would look like this:

    docker run --rm -v <SOURCE_DATA_VOLUME_NAME>:/from alpine ash -c "cd /from ; tar -cf - . " | ssh <TARGET_HOST> 'docker run --rm -i -v <TARGET_DATA_VOLUME_NAME>:/to alpine ash -c "cd /to ; tar -xpvf - " 

    You will need to change:


    Or, you could try using this helper script

    Hope this helps.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.