The contents of GitHub repo not in volume

I’ve had a lot of issues the past few days to try and get named servers to work with persistent volumes that are filled with GitHub repo contents. I’ve done a lot of digging and stumbled on to the underlying note in the documentation that says:

The contents of your GitHub repository might not show up if you have enabled persistent storage. Disable persistent storage if you want the Git repository contents to show up.

Link to docs:

Can someone clarify this note please and what I can do about it to make it work, I’ve got it to work without persistent storage but the storage is a must for me.

Have a look at

Your storage is initially empty because it’s a new volume that’s mounted on top of where the original home directory used to be. Since it’s meant to persist between containers you have to be careful not to overwrite any notebooks or data that a user has created or modified.

If I understand correctly I need to define a hook that copies the files to my persistent volume. But each time a server restarts this copy will occur resulting in overwriting whatever the user has done.

So the following situation is impossible to achieve? The first time the server starts copy github content to persistent volume, when the server restarts do not copy again to prevent losing user changes.

I’d like to go down this route by copying the files into the home directory but I can’t seem to find where repo2docker stores it files.

Your hook is a shell command or script so you can check whether a file exists, and only populate the volume if it doesn’t.

Do you know where the repo2docker files are stored so I can copy them?

repo2docker copies the files into the container image when it’s built, not when it’s run. That’s why if you don’t mount a volume you can see all the files in your home directory, but if you mount an external volume on top of your home directory it hides the existing files. This means there’s no way to access your original files after you’ve mounted the volume on top of home.

If you use nbgitpuller it’ll download the files from git.

repo2docker added a --target-repo-dir argument, which sets the repo location within the image. If you are using repo2docker to build images, you might want to set this option to put repo contents elsewhere in the image. You can then use hooks either staging files from here or nbgitpuller to populate home as appropriate.