1

I am relatively new to docker. I want to use a database with volume to persist. I am in windows 10.

I want to check where the volumns are created in my machine.

When i run the command

C:\Users\satul>docker volume inspect 368984d12c3525d8752d249347cfd563afb46c847e1c109afa9785bf54b89701 [
    {
        "CreatedAt": "2018-06-25T22:43:29Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/368984d12c3525d8752d249347cfd563afb46c847e1c109afa9785bf54b89701/_data",
        "Name": "368984d12c3525d8752d249347cfd563afb46c847e1c109afa9785bf54b89701",
        "Options": null,
        "Scope": "local"
    } ]

Since this is a windows box, i donot have folder /var/lib/docker/volumes/. Where exactly is the volumn folder in windows so that i can backit up if required.

1
  • Please see if this link helps.
    – Rao
    Jun 26, 2018 at 5:55

2 Answers 2

0

You should not back up volumes by backing up /var/lib/docker/volumes directory. Instead you should use command (it will create the backup in your current working directory):

docker run --rm --volumes-from container-name -v $(pwd):/backup ubuntu tar cvf /backup/backup_name.tar /mount/point/inside/container

Eg. for Docker registry the command looks like this:

docker run --rm --volumes-from registry -v $(pwd):/backup ubuntu tar cvf /backup/registry_backup.tar /var/lib/registry

And to restore the backup you should use command:

docker run --rm --volumes-from container-name -v $(pwd):/backup ubuntu bash -c "cd /mount/point/inside/container && tar xvf /backup/registry_backup.tar --strip number_of_leading_directory_components_in_mount_point_path"

Eg. to restore backup of Docker registry:

docker run --rm --volumes-from registry -v $(pwd):/backup ubuntu bash -c "cd /var/lib/registry && tar xvf /backup/registry_backup.tar --strip 3"
-1

Usually /var/lib/docker is mounted on C:\Users\Public\Documents\Hyper-V\Virtual hard disks. You can check it out by looking at your docker settings.

A docker volume is just a directory on your host machine with all your container data, so you could use any methods you wish to backup your data.You can see more about docker volumes in official documentation

See also

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.