Installing a jupyter notebook extension on Binderhub

Hello!

I’m running an instance of Binderhub locally via minikube. If I launch a notebook, I can install a notebook extension by running some code in a cell. I’d like to have the extension loaded before opening the notebook, and I’m confused over how to accomplish this.

I found this example that uses a postBuild script, but how exactly would this be implemented? I tried adding it to the repo I’m using to build an image, but haven’t had any luck. Is there something I’m missing?

Thanks!

Your repository has a Dockerfile in it which means BinderHub just does what is listed in the file instead of using the cleverness of repo2docker (the tool that makes Binder magic) to work what it should do. Most repositories only specify files like requirements.txt and/or postBuild and then let repo2docker figure out what that right thing to do is. It understands lots of configuration files so most of the time you don’t have to write your own Dockerfile.

In case you really do want to write you own Dockerfile adding something like

COPY postBuild postBuild
RUN ./postBuild

to it will probably work.

TL;DR: if you write your own Dockerfile repo2docker will assume you need to do special stuff it doesn’t support and follow it to the letter. This means you have to spell everything out. Without a Dockerfile present repo2docker will use its smarts to figure out what it should be doing and you don’t have to write a Dockerfile at all.

1 Like

Thanks for your reply @betatim! Didn’t realize that having a Dockerfile would override everything repo2docker does.
I’ve removed the DockerFile from my test repo and added a requirements.txt. The extension still doesn’t load in the notebook UI, but I see it listed in the Nbextensions tab with the message “possibly incomplete” so I’m probably not installing it/loading it correctly. Still trying to troubleshoot that, but at least I know why it wasn’t loading at all in the first place.

Thanks again!

1 Like