You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
name: py-env
services:
jupyter:
build:
context: .
args:
CONDA_ENV_NAME: py-env
image: py-env:latest
user: root # This is a must in order for env var user switch to take effect
restart: always
ports:
- "8888:8888"
volumes:
- "/path/on/my/host/jovyan:/home/jovyan"
environment:
NB_UID: "1005"
NB_GID: "1005"
CHOWN_HOME: "yes"
CHOWM_HOME_OPTS: "-R"
deploy:
resources:
reservations:
devices:
- capabilities: [gpu] # Ensure the container has access to GPUs
runtime: nvidia # Specify the use of NVIDIA runtime for GPU support
How to Reproduce the problem?
I manually created the /path/on/my/host/jovyan path with non-root user.
Here is Dockerfile:
FROM quay.io/jupyter/minimal-notebook
# Name your environment and choose the Python version
ARG CONDA_ENV_NAME=my-env
ENV LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${CONDA_DIR}/envs/${CONDA_ENV_NAME}/lib"
USER root
RUN apt-get update && \
apt-get install -y \
openjdk-21-jdk \
libopenmpi-dev && \
apt-get clean
# USER ${NB_UID}
# Create conda environment from env1.yaml file
COPY --chown=${NB_UID}:${NB_GID} env1.yaml /tmp/
RUN mamba env create -p "${CONDA_DIR}/envs/${CONDA_ENV_NAME}" -f /tmp/env1.yaml && \
mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Create Python kernel and link it to jupyter
RUN "${CONDA_DIR}/envs/${CONDA_ENV_NAME}/bin/python" -m ipykernel install --user --name="${CONDA_ENV_NAME}" && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# Install from the requirements.txt file
COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/
RUN "${CONDA_DIR}/envs/${CONDA_ENV_NAME}/bin/pip" install --upgrade pip && \
"${CONDA_DIR}/envs/${CONDA_ENV_NAME}/bin/pip" install --no-cache-dir --requirement /tmp/requirements.txt && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# seperating tensorrt_llm from requirements.txt because it needs different index url
RUN "${CONDA_DIR}/envs/${CONDA_ENV_NAME}/bin/pip" install --no-cache-dir tensorrt_llm --extra-index-url https://pypi.nvidia.com && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
# This changes the custom Python kernel so that the custom environment will
# be activated for the respective Jupyter Notebook and Jupyter Console
# hadolint ignore=DL3059
# RUN /opt/setup-scripts/activate_notebook_custom_env.py "${CONDA_ENV_NAME}"
# Comment the line above and uncomment the section below instead to activate the custom environment by default
# Note: uncommenting this section makes "${CONDA_ENV_NAME}" default both for Jupyter Notebook and Terminals
# More information here: https://github.com/jupyter/docker-stacks/pull/2047
USER root
RUN \
# This changes a startup hook, which will activate the custom environment for the process
echo conda activate "${CONDA_ENV_NAME}" >> /usr/local/bin/before-notebook.d/10activate-conda-env.sh && \
# This makes the custom environment default in Jupyter Terminals for all users which might be created later
echo conda activate "${CONDA_ENV_NAME}" >> /etc/skel/.bashrc && \
# This makes the custom environment default in Jupyter Terminals for already existing NB_USER
echo conda activate "${CONDA_ENV_NAME}" >> "/home/${NB_USER}/.bashrc"
COPY docker-compose.yaml /home/jovyan/docker-compose-files/docker-compose.yaml
USER ${NB_UID}
Command output
Expected behavior
I expected /home/jovyan to be mounted to host`s directory with everything inside of container working.
Actual behavior
It seems like that my conda environment is not being created as expected. Also, when I open the terminal the conda environment is not automatically activated.
Anything else?
When I mount "/path/on/my/host/jovyan:/home/jovyan/work" everything works fine.
I want to achieve this because some libraries like tensorrt_llm tend to download LLMs in /home/jovyan and not /home/jovyan/work which I want to avoid.
Latest Docker version
I've updated my Docker version to the latest available, and the issue persists
The text was updated successfully, but these errors were encountered:
Currently having something in home/jovyan from both container and the bind mount is not supported.
I think the best you can do is mount to /home/jovyan/work, but at the same time change the cmd to start-notebook.py --ServerApp.root_dir=/home/jovyan/work
This way you won't notice that the mount dir is work/ and new tab will open in this directory.
Also, there is a typo in the name CHOWM_HOME_OPTS you use.
What docker image(s) are you using?
minimal-notebook
Host OS
Rocky Linux 9.5
Host architecture
x86_64
What Docker command are you running?
I am running docker compose file:
How to Reproduce the problem?
I manually created the
/path/on/my/host/jovyan
path with non-root user.Here is Dockerfile:
Command output
Expected behavior
I expected
/home/jovyan
to be mounted to host`s directory with everything inside of container working.Actual behavior
It seems like that my conda environment is not being created as expected. Also, when I open the terminal the conda environment is not automatically activated.
Anything else?
When I mount "/path/on/my/host/jovyan:/home/jovyan/work" everything works fine.
I want to achieve this because some libraries like
tensorrt_llm
tend to download LLMs in/home/jovyan
and not/home/jovyan/work
which I want to avoid.Latest Docker version
The text was updated successfully, but these errors were encountered: