Hi! I’m trying to create a custom image to use it in singleuser Jupyterhub on k8s.
I would need to create a jupyter image that has Python version 3.12 and create a custom kernel via poetry.
This is the configuration of my Dockerfile:
FROM quay.io/jupyter/minimal-notebook:python-3.12
USER root
RUN apt-get update && apt-get install -y \
build-essential \
python3-dev \
libffi-dev \
curl \
postgresql-client \
libpq-dev \
gfortran \
libopenblas-dev \
iputils-ping \
git \
openssh-client \
&& rm -rf /var/lib/apt/lists/*
ENV POETRY_VERSION=1.8.2
ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache
ENV PATH="${PATH}:${POETRY_VENV}/bin"
RUN python3 -m venv $POETRY_VENV \
&& $POETRY_VENV/bin/pip install -U pip setuptools \
&& $POETRY_VENV/bin/pip install poetry==${POETRY_VERSION}
RUN mkdir -p /root/.ssh
RUN chmod 0700 /root/.ssh
COPY known_hosts /root/.ssh/known_hosts
COPY id_rsa /root/.ssh/id_rsa
COPY id_rsa.pub /root/.ssh/id_rsa.pub
RUN chmod 600 /root/.ssh/id_rsa
RUN chmod 600 /root/.ssh/id_rsa.pub
COPY poetry.lock pyproject.toml ./
RUN poetry lock --no-update && poetry install --no-interaction --no-cache
RUN poetry run pip install ipykernel
RUN poetry run python -m ipykernel install --user --name new-kernel --display-name "new-kernel"
EXPOSE 8888
# CMD ["poetry", "run", "jupyter-lab", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--no-browser", "--allow-root"]
As soon as I start the server, however, I get the following error:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/jupyter_server/serverapp.py", line 2813, in initialize
self.init_configurables()
File "/opt/conda/lib/python3.12/site-packages/jupyter_server/serverapp.py", line 2087, in init_configurables
"connection_dir": self.runtime_dir,
^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/traitlets/traitlets.py", line 687, in __get__
return t.cast(G, self.get(obj, cls)) # the G should encode the Optional
^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/traitlets/traitlets.py", line 635, in get
default = obj.trait_defaults(self.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/traitlets/traitlets.py", line 1897, in trait_defaults
return t.cast(Sentinel, self._get_trait_default_generator(names[0])(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.12/site-packages/jupyter_core/application.py", line 111, in _runtime_dir_default
ensure_dir_exists(rd, mode=0o700)
File "/opt/conda/lib/python3.12/site-packages/jupyter_core/utils/__init__.py", line 26, in ensure_dir_exists
Path(path).mkdir(parents=True, mode=mode)
File "/opt/conda/lib/python3.12/pathlib.py", line 1311, in mkdir
os.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/home/jovyan/.local/share/jupyter/runtime'
How can I solve this? are there guides to building an image with poetry and python 3.12?
Building the image from scratch with python3.12 when I start the server I get:
Thanks