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.

  • How can I provision a Docker image using Ansible without installing locally?
  • Ansible roles task failing docker swarm node join
  • Why doesn't the docker volume in Windows Server show up when I run this command?
  • Docker --link not adding two entries to hosts file
  • Docker pull error
  • How to specify Memory & CPU limit in docker compose version 3
  • 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

  • Docker runs of “pip install” and “npm install” on same container overwriting each other
  • Using Jenkins Blue Ocean to Deploy builds
  • Gitlab CI - Use docker image offline
  • How to use child_process inside nodejs application running inside docker container
  • How to isolate builds in jenkins using docker
  • Do you have to remove all stacks at once with docker?
  • 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.