#### Exporting a Docker Container and Volume

I have some academic code that I want to share in a self-contained environment, so that various experimental results can be replicated.

My approach so far is a docker container, with a few build scripts to add the required dependencies, and a volume containing the actual code and data.

The Dockerfile seems easy to share, and this will recreate the state of the container; then, someone else would need to start a docker container with the volume, so I need to export the volume.

I’ve tried the steps in Backup a container and this answer, but I’m not sure exactly what needs to happen.

The volume is called offline-simon-vol and I started a container testcont using

docker run -v offline-simon-vol --name testcont ubuntu /bin/bash

and then I tried to run

 docker run --rm --volumes-from testcont -v $(pwd)/backup ubuntu tar cvf /backup.backup.tar offline-simon-vol which executes without error, but I have no idea where the backed up volume is! I can’t find the documentation on what all of these flags do. As far as I can tell, this is starting a new instance of the "ubuntu" container, but loading all the volumes that are in testcont. I don’t know what $(pwd)/backup is doing; the answer I linked seems to say that this is the location where the exported volume will appear, but nothing new appears in the working directory.

The tar command at the end should be compressing offline-simon-vol to /backup.backup.tar (I think). But /backup.backup.tar doesn’t appear in the root directory when this command finishes. I also don’t understand why the output filename should start with /backup, rather than, e.g., the working directory.

Finally, the answer I linked has /data instead of the volume’s name as the final word, but when I use /data it just gives me a tar: /data: Cannot stat: No such file or directory error.

What can I do to find the exported volume, or export it into a specific place? Also, is this the best way to export my code and data for reproducibility?

Source: Docker Questions