Windows docker container volume backup

Expected behavior

Take backup of windows docker container volume backup

Actual behavior

Not clear about how to take backup of volume. Found some commands in stack overflow. But they are not working in windows.


I am very new to windows docker.
I am able to take backup (.tar) file of container image. Using “commit” and “save” command.
But not able to take backup of volume. Might be i am following some wrong steps.

I have gone through site

And running command: docker run --volumes-from vol1demo -v c:\Target microsoft/nanoserver tar xvf c:\Backup\backup.tar vol1

Here my understanding is,

vol1demo: container name.
-v: Path of volume destination directory. Created in container while attaching volume.
microsoft/nanoserver: Container base OS image.
tar xvf c:\Backup\backup.tar: Directory “Backup” present in c: in Host machine.
vol1: Volume name attached to container vol1demo.

  • the output of:
    using Powershell on Windows
    C:\Program Files\Docker\docker.exe: Error response from daemon: container 294ac4a0305593688930c2ec210e4212839b9b25e343a24a104baf68cf671f07 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2) extra info: {“ApplicationName”:"",“CommandLine”:“tar xvf c:\Backup\backup.tar vol1”,“User”:"",“WorkingDirectory”:“C:\”,“Environment”:{},“EmulateConsole”:false,“CreateStdInPipe”:true,“CreateStdOutPipe”:true,“CreateStdErrPipe”:true,“ConsoleSize”:[0,0]}.

Steps to reproduce the behavior

  1. …Run command: docker run --volumes-from vol1demo -v c:\Target microsoft/nanoserver tar xvf c:\Backup\backup.tar vol1
  2. … Get above output.

Please can anyone help here?

You should be able to backup a given volume on Windows with that command:

docker run --rm --volume vol1demo:/source --volume c:\Backup:/backup ubuntu tar -cvf vol1demo.tar -C /source .

And to restore:

docker create vol2demo
docker run --rm --volume c:\Backup:/backup --volume vol2demo:/restore ubuntu tar -xvf /backup/vol1demo.tar -C /restore

The vol2demo container will have a directory /restore which has the files from the archive. So if you want to use those files, once the volume is mounted you have to login and move them to the parent folder.

1 Like

Some more commands that worked for me in Powershell CLI.

docker run --rm --volumes-from wiki-js_db_1 -v c:\volbackup:/backup ubuntu tar -cvf /backup/backup.tar -C /var/lib/postgresql/data .


docker run --rm --volumes-from wiki-js_db_1 -v c:\volbackup:/backup ubuntu bash -c "cd /var/lib/postgresql/data && tar xvf /backup/backup.tar --strip 1"


  • wiki-js_db_1 is the name of the container not the volume in my example
  • The colon in the between c:\volbackup and /backup denotes that the the folder within the volume /backup will be mounted within the local filesystem at c:\volbackup
  • The end ‘.’ is required for the backup command to actually tar the contents of the folder

In general, --mount is more explicit and verbose. The biggest difference is that the -v syntax combines all the options together in one field, while the --mount syntax separates them. Here is a comparison of the syntax for each flag.

If you need to specify volume driver options, you must use --mount.

-v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious.
In the case of named volumes, the first field is the name of the volume and is unique on a given host machine. For anonymous volumes, the first field is omitted.
The second field is the path where the file or directory is mounted in the container.
The third field is optional and is a comma-separated list of options, such as ro. These options are discussed below.
–mount: Consists of multiple key-value pairs, separated by commas and each consisting of a = tuple. The --mount syntax is more verbose than -v or --volume, but the order of the keys is not significant, and the value of the flag is easier to understand.
The type of the mount, which can be bind, volume, or tmpfs. This topic discusses volumes, so the type is always volume.
The source of the mount. For named volumes, this is the name of the volume. For anonymous volumes, this field is omitted. May be specified as source or src.
The destination takes as its value the path where the file or directory is mounted in the container. May be specified as the destination, dst, or target.
The read-only option, if present, causes the bind mount to be mounted into the container as read-only.
The volume-opt option, which can be specified more than once, takes a key-value pair consisting of the option name and its value.

Hope this helps,
Jerry M.