Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Image Docker Spawner #236

Closed
nils-werner opened this issue Jun 7, 2018 · 2 comments · Fixed by #219
Closed

Multi Image Docker Spawner #236

nils-werner opened this issue Jun 7, 2018 · 2 comments · Fixed by #219

Comments

@nils-werner
Copy link

nils-werner commented Jun 7, 2018

This is less a bug, and also not quite a pull request, but more an idea or a recipe: You can allow users to chose the docker image they are using upon starting their server by using something like the following

from dockerspawner import SystemUserSpawner

class MultiDockerImageSpawner(SystemUserSpawner):
    images = {
        'SciPy': 'jupyter/scipy-notebook:0f73f7488fa0',
        'Tensorflow': 'jupyter/tensorflow-notebook:59904dd7776a',
        'R': 'jupyter/r-notebook:59904dd7776a',
    }
    def _options_form_default(self):
        outval = """
        <label for="image">Docker Image</label>
        <select name="image">
        """
        for name, image in self.images.items():
            outval += "<option value=\"%s\">%s (%s)</option>" % (name, name, image)

        outval += """
        </select>
        """
        return outval

    def options_from_form(self, formdata):
        options = {}
        options['image'] = formdata.get('image', ['SciPy'])[0]
        self.image = self.images[options['image']]
        return options

@minrk what do you think about this? would you be interested in wrapping this up in a class that goes in the codebase?

@minrk
Copy link
Member

minrk commented Jun 13, 2018

This is very much like what I drafted in #219. I should finish that up!

@nils-werner
Copy link
Author

Ah, didn't see that, sorry :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants