Describe the bug
While trying to add some additional functionality to a derived version of the ipex-xpu-jupyter container, attempting to access the shell results in bash complaining that conda does not exist:
docker run -it --rm \
-p 8888:8888 \
--net=host \
--device /dev/dri \
-v /dev/dri/by-path:/dev/dri/by-path \
--ipc=host \
intel/intel-extension-for-pytorch:2.1.20-xpu-pip-jupyter \
/bin/bash
WARNING: Published ports are discarded when using host network mode
bash: conda: command not found
Conda is not installed in the intel-xpu-base layer, nor intel-xpu-jupyter layer. However, the Dockerfile layer for intel-xpu-jupyter is adding 'conda activate idp' regardless. This is due to this check in the Dockerfile:
RUN if [ ! -d "$(which conda)" ]; then \
echo "conda activate idp" >> ~/.bashrc; \
fi
That check is attempting to check if conda exists, and then add the conda activate idp
to the .bashrc.
However, which
returns the path to the executable (if it is in the path) and not a file. The the '-d' check will fail if conda is installed (which returns file path) and if conda is not installed (which returns nothing, so no directory). The '!' inverts that failure to be success. The net result is the conda command will be added to ~/.bashrc regardless of whether conda exists or not.
A corrected line:
# If conda is in the path, activate idp environment
RUN if $(which conda >/dev/null); then \
echo "conda activate idp" >> ~/.bashrc \
fi
The instructions are also telling the user to publish a port (-p) and use --net=host; you shouldn't need --net=host since you are publishing the internal port 8888 to the host port 8888.
Error Logs
WARNING: Published ports are discarded when using host network mode
bash: conda: command not found
Reproduction Instructions
docker run -it --rm \
-p 8888:8888 \
--net=host \
--device /dev/dri \
-v /dev/dri/by-path:/dev/dri/by-path \
--ipc=host \
intel/intel-extension-for-pytorch:2.1.20-xpu-pip-jupyter \
/bin/bash
Affected Subfolder
Versions
intel/intel-extension-for-pytorch:2.1.20-xpu-pip-jupyter