so

Polynote in Docker

Volume 3, Issue 29; 26 Oct 2019

My quick hack to get polynote running in docker.

I’ve been interested in what I guess are called “interactive notebooks” since I first encountered them. The Jupyter notebooks seem to be the most common example. I’ve played with them once or twice, but I’ve never really used them. That said, I get a lot of milage out of babel in Org mode, which offers at least similar functionality,

Earlier today, I stumbled across the Polynote notebooks. Support for Scala was enough to pique my interest so I thought I’d give them a try. I don’t really want to install all of the dependencies for running polynote on my laptop so this is an ideal application for containers;

I quickly found the pyspark image, but it wouldn’t quite run polynote. A cursory web search didn’t turn up anything for polynote, so I set out to build it myself.

It was a tiny bit tricky, perhaps because I’m still something of a Docker novice, but I thought I’d share it in case it saves someone a little time:

[27 October 2019: Small update. I added a symlink for pip3 because the pyspark base image doesn't have one and the polynote startup script uses it to find jep.]

FROM jupyter/pyspark-notebook
MAINTAINER Norman Walsh <ndw@nwalsh.com>

USER root
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y openjdk-8-jdk-headless
RUN ln -s /opt/conda/bin/pip /opt/conda/bin/pip3

ADD polynote-dist.tar.gz /tmp/polynote-dist.tar.gz
RUN mv /tmp/polynote-dist.tar.gz/polynote /home/jovyan/
ADD config.yml /tmp/
RUN cp /tmp/config.yml /home/jovyan/polynote/
RUN chown -R jovyan polynote
RUN chgrp -R users polynote

USER $NB_UID

ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
RUN pip install jep jedi pyspark virtualenv

WORKDIR /home/jovyan/polynote

CMD [ "./polynote" ]

The only thing in config.yml is

listen:
  host: 0.0.0.0
  port: 8888

I couldn’t get access to work on the default port of 8192, but maybe the reason for that will become clear when I’m less jet lagged.

Share and enjoy.