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

Customizing Dockerfile #1425

Closed
dlsun opened this issue Sep 15, 2017 · 10 comments
Closed

Customizing Dockerfile #1425

dlsun opened this issue Sep 15, 2017 · 10 comments

Comments

@dlsun
Copy link

dlsun commented Sep 15, 2017

I followed the Zero to JupyterHub tutorial and was able to get a running instance of JupyterHub on Google Cloud. Thanks so much for this awesome tutorial. It was very easy to follow for a complete novice like me.

I'm now trying to customize the image. I would like to pull Python code from Github and install the package. I tried creating a Dockerfile with the following contents:

FROM jupyter/scipy-notebook:2d878db5cbff

RUN conda install --quiet --yes \
  'setuptools=36.4.0'

RUN cd /tmp && \
    git clone https://github.com/dlsun/symbulate.git && \
    python symbulate/setup.py install && \
    rm -rf symbulate

The Dockerfile builds without any problem. I'm even able to apply the config changes using helm. The problem comes when I actually try to log in to JupyterHub (I'm using Github authentication) and start up my server. I get the error:

oci runtime error: container_linux.go:247: starting container process caused \"chdir to cwd (\\\"/home/jovyan/work\\\") set in config.json failed: no such file or directory

Any ideas on what I should do?

@Analect
Copy link
Contributor

Analect commented Sep 15, 2017

@dlsun
Perhaps I can help.

So the default image in the helm-chart (zero-to-jupyterhub) is this one built with this Dockerfile here: https://github.com/jupyterhub/helm-chart/blob/master/images/singleuser-sample/Dockerfile

You will need to structure your own image in a broadly similar way ... in terms of installing jupyterhub on the image itself (you'll probably need version 0.7.2). Also note the creation of user jovyan and exposing port 8888 etc, as per that default Dockerfile. Try to align your Dockerfile structure as much to this default one as you can, allowing for the fact that you may be building from a different base and installing other packages.

You will then have to over-ride the default helm-chart with your new image. To do that, you add it to your config.yaml file (the one where you added a client-id and secret). The deployment.yaml in the helm-chart will know to look there for any new image.

https://github.com/jupyterhub/helm-chart/blob/master/jupyterhub/templates/hub/deployment.yaml#L56

So your config.yaml file will have a section something like this:

singleuser:
  image:
    name: your-image-registry/your-image-name
    tag: your-image-tag    

@yuvipanda
Copy link
Contributor

@dlsun that error indicates that you are probably using a really old version of docker-stacks as base. jupyter/docker-stacks@2d878db looks like it's from mid-2016. Can you use a newer base image? docker-stacks images older than a few months will give this error.

@dlsun
Copy link
Author

dlsun commented Sep 15, 2017

@Analect Since my base is jupyter/scipy-notebook, shouldn't I already have everything that is in that default Dockerfile?

@yuvipanda I changed to jupyter/scipy-notebook:latest and I'm getting the same error. :-(

@yuvipanda
Copy link
Contributor

Can you add a 'WORKDIR $HOME' to the end of your Dockerfile?

@dlsun
Copy link
Author

dlsun commented Sep 15, 2017

@yuvipanda I'm still getting the same error message.

@dlsun
Copy link
Author

dlsun commented Sep 15, 2017

To be clear, my Dockerfile now looks like:

FROM jupyter/scipy-notebook:latest

RUN conda install --quiet --yes \
  'setuptools=36.4.0'

RUN cd /tmp && \
    git clone https://github.com/dlsun/symbulate.git && \
    python symbulate/setup.py install && \
    rm -rf symbulate

WORKDIR $HOME

@yuvipanda
Copy link
Contributor

hmm, can you share your config.yaml? Also are you sure the new docker image is being used? Did you build and push a new tag with it?

@dlsun
Copy link
Author

dlsun commented Sep 15, 2017

@yuvipanda Thanks for helping me with this.

I ran the following command (from the directory with the Dockerfile) to build the image: docker build . -t us.gcr.io/stat-350/symbulate

Then I pushed the image to Google Cloud Registry: gcloud docker -- push us.gcr.io/stat-350/symbulate

Here is the singleuser part of my config.yaml file:

singleuser:
  image:
    name: us.gcr.io/stat-350/symbulate
    tag: latest
  memory:
    limit: 2G
    guarantee: 2G

which I upgrade by running the following command (from the directory containing config.yaml): helm upgrade stat350-jupyterhub jupyterhub/jupyterhub --version=v0.4 -f config.yaml

@yuvipanda
Copy link
Contributor

Can you try using an explicit tag instead of 'latest'? so you'd do:

docker build . -t us.gcr.io/stat-350/symbulate:

and then gcloud docker -- push us.gcr.io/stat-350/symbulate:

and put that tag in singleuser.image instead of 'latest'?

Also can you try running the image manually after building it to see if that works? You can do that with:

docker run -it us.gcr.io/stat-350/symbulate:<some-tag> /bin/bash

and tell me what that produces?

@dlsun
Copy link
Author

dlsun commented Sep 21, 2017

Thanks for all the help. I ended up deleting my Google Cloud container and making it from scratch, and that seems to have fixed the problem.

@dlsun dlsun closed this as completed Sep 21, 2017
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

No branches or pull requests

3 participants