0

I have taken some time to create a useful Docker volume for use at work. It has a restored backup of one of our software databases (SQL Server) on it, and I use it for testing/debug by just attaching it to whatever Linux SQL Container I feel like running at the time.

When I make useful Docker images at work, I share them with our team using either the Azure Container Registry or the AWS Elastic Container Registry. If there's a DockerFile I've made as part of a solution, I can store that in our GIT repo for others to access.

But what about volumes? Is there a way to share these with colleagues so they don't need to go through the process I went through to build the volume in the first place? So if I've got this 'databasevolume' is there a way to source control it? Or share it as a file to other users of Docker within my team? I'm just looking to save them the time of creating a volume, downloading the .bak file from its storage location, restoring it etc.

JamesMatson
  • 2,522
  • 2
  • 37
  • 86
  • 1
    The volume is nothing more than files in a folder, if managed by docker, then by default the volumes are stored in `/var/lib/docker/volumes` - you can [compress the files inside the volume and share them with your colleagues](https://docs.docker.com/storage/volumes/#backup-a-container) like that (create the volume, run a container and unpack the archive to populate the volume). You can't export or save a volume. Another possibility to to create the volume backed by an NFS share however then it'd be central cf. a copy for everyone. – masseyb Mar 06 '21 at 10:42
  • Thanks. So generally speaking, it's acceptable that people just set up their own volumes? And the best thing we can do to assist with automating/lessening the manual work is perhaps providing a script to automate the download of the db backup etc? – JamesMatson Mar 06 '21 at 11:12
  • 1
    Precisely, yes. Could automate a backup to a NFS share available to everyone on your host and a “drop and recreate volume on your colleagues hosts” (if it’s read-only data and your colleagues copies will never change) or go for SOP’s for managing docker volumes and still automate the backups to a NFS drive. Really depends on what you need at that point but there is no built in docker functionality to export a volume. – masseyb Mar 06 '21 at 11:20
  • 1
    Thanks you've been most helpful masseyb. Can you create your comment as an answer so I can give credit? :) – JamesMatson Mar 06 '21 at 11:23
  • 1
    If it’s RO for the colleagues, could do a mix, create a volume backed by a NFS drive that all of your colleagues can mount in their local environment which is a copy of your local volume that you backup and restore at regular intervals. – masseyb Mar 06 '21 at 11:23

1 Answers1

0

The short answer is that there is no default docker functionality to export the contents of a docker volume and docker export explicitly does not export the contents of the volumes associated with the container. You can backup, restore or migrate data volumes.

Note: if your're backing up a database I'd suggest using the appropriate tools for that database.

masseyb
  • 3,745
  • 1
  • 17
  • 29