Launcher to show additional kernels that are for different conda environments

Hello everyone,
My goal is to get Z2JH system on a VM running on our local network. My main goal will be to get the Launcher to show addition kernels that are for different conda environments.
To do this I will be following the instructions at this link: Customizing User Environment — Zero to JupyterHub with Kubernetes documentation
I will list the dockerfille as I make various attempts to get this working.
Here is my first dockerfile attempt:

FROM jupyter/all-spark-notebook:2022-04-04
RUN conda init bash
WORKDIR /home/jovyan
COPY ./.condarc .
COPY ./env-etl.yml .
RUN conda env create -f env-etl.yml
SHELL [“conda”, “run”, “-n”, “etl”, “/bin/bash”, “-c”]
RUN ipython kernel install --user --name=etl

#Results for dockerfile #1 attempt:
The ETL kernel did not show up in the launcher.
No .bashrc file was created.
No conda environment was created.
No modules listed in the env-etl.yml were installed.

Attempt #2
Before I tried updating the dockerfile again I ran the following commands from
the JH terminal:
conda init bash
&& . ~/.bashrc
&& conda install --quiet --yes nb_conda_kernels \
&& conda create --quiet --yes --name test-env python=3.7
&& conda activate test-env
&& conda install --quiet --yes ipykernel
&& ipython kernel install --user --name=test-env
Results:
This created a new kernel in the launcher called test-env as desired.

dockerfile 2:
FROM jupyter/minimal-notebook:latest
RUN conda init bash
&& . ~/.bashrc
&& conda install --quiet --yes nb_conda_kernels \
&& conda create --quiet --yes --name test-env python=3.7

SHELL [“conda”, “run”, “-n”, “test-env”, “/bin/bash”, “-c”]

RUN conda install --quiet --yes ipykernel
&& ipython kernel install --user --name=test-env

Result:
The launcher showed Python 3 (ipykernel), Python [conda env:root] *, and Python [conda env:test-env]
From a terminal conda env list shows a base and test-env.
no /home/jovyan/.bashrc file was create.

Attempt 3:
Want to get the .bashrc file or the user wont be able to call conda create until they run it.

dockerfile:
FROM jupyter/minimal-notebook:latest
USER root
ENV GRANT_SUDO=“yes”
COPY ./.bashrc /opt/conda/
RUN cat /opt/conda/.bashrc >> /etc/bash.bashrc

USER ${NB_UID}
WORKDIR /home/jovyan

RUN conda install --quiet --yes nb_conda_kernels \
&& conda create --quiet --yes --name test-env python=3.7

SHELL [“conda”, “run”, “-n”, “test-env”, “/bin/bash”, “-c”]

RUN conda install --quiet --yes ipykernel
&& ipython kernel install --user --name=test-env

Here is the .bashrc file:
__conda_setup="$(’/opt/conda/bin/conda’ ‘shell.bash’ ‘hook’ 2> /dev/null)"
if [ $? -eq 0 ]; then
eval “$__conda_setup”
else
if [ -f “/opt/conda/etc/profile.d/conda.sh” ]; then
. “/opt/conda/etc/profile.d/conda.sh”
else
export PATH="/opt/conda/bin:$PATH"
fi
fi
unset __conda_setup

Results: The kernels appear in the launcher, except I would like to get rid of the Python [conda env:root] * one. The terminal opens and displays the conda prompt.

Questions Left:

  1. How to remove the Python [conda env:root] * kernel.
  2. How to change the display name from Python [conda env:test-env] to Python (test-env).

I could not install additional conda modules without giving write privileges to /opt/conda/env.
Here is the updated dockerfile.
The above 2 questions I still can not figure out and would appreciate any help.
Thank you

Append the following to the above dockerfile. Could not list the whole file because the system said I was limited to 2 links in posts.

RUN chmod -R 777 /opt/conda/envs
USER ${NB_UID}

Hi! For future reference you can format your code as code blocks: Creating and highlighting code blocks - GitHub Docs
This will make it easier to understand your Dockerfiles.

One thing I noticed is you making changes to /home/jovyan in your Dockerfile. You haven’t shared your Z2JH config, but if you’re using the the default then a persistent volume is mounted which means those changes will be hidden.