I have the following Dockerfile:
# set the base image
FROM ubuntu:latest
# set python image
FROM python:3
# run update and setup functions
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y build-essential python-dev-is-python3
RUN apt-get install -y python-is-python3 2to3
RUN pip install pip --upgrade
# run jupyter install
RUN pip install jupyter
# set the working directory
WORKDIR /home/jupyter
# add python libraries
ADD requirements.txt /home/jupyter/
# make notebooks directory
RUN mkdir /home/jupyter/notebooks
# run the requirements.txt to pip install
RUN pip install -r requirements.txt
# run docker container with Jupyter Notebook
CMD ["jupyter", "notebook", "--allow-root", "--no-browser", "--ip 0.0.0.0", "--port 8888", "./notebooks"]
This Dockerfile builds just fine without errors:
PS C:<local_path>Docker> docker build --tag notebook .
[+] Building 292.3s (15/15) FINISHED docker:desktop-linux
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 805B 0.0s
=> [internal] load metadata for docker.io/library/python:3 0.2s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [stage-1 1/10] FROM docker.io/library/python:3@sha256:785fef11f44b7393c03d77032fd72e56af8b05442b051a15122914 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 38B 0.0s
=> CACHED [stage-1 2/10] RUN apt-get update && apt-get -y upgrade 0.0s
=> CACHED [stage-1 3/10] RUN apt-get install -y build-essential python-dev-is-python3 0.0s
=> CACHED [stage-1 4/10] RUN apt-get install -y python-is-python3 2to3 0.0s
=> CACHED [stage-1 5/10] RUN pip install pip --upgrade 0.0s
=> CACHED [stage-1 6/10] RUN pip install jupyter 0.0s
=> CACHED [stage-1 7/10] WORKDIR /home/jupyter 0.0s
=> CACHED [stage-1 8/10] ADD requirements.txt /home/jupyter/ 0.0s
=> CACHED [stage-1 9/10] RUN mkdir /home/jupyter/notebooks 0.0s
=> [stage-1 10/10] RUN pip install -r requirements.txt 271.3s
=> exporting to image 20.7s
=> => exporting layers 20.7s
=> => writing image sha256:3a4066929f1f16f0d66749dd13155526c280170e29284032bd6a64bd12f87267 0.0s
=> => naming to docker.io/library/notebook 0.0s
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/h8u0s757guiu9enx1xqsjvj7k
What's next:
View a summary of image vulnerabilities and recommendations → docker scout quickview
Then I run the following docker run -p 8888:8888 -v C:/<local_path>:/home/jupyter/notebooks notebook
and receive the following error: [C 2024-10-04 02:09:02.474 ServerApp] No such file or directory: /home/jupyter/--ip 0.0.0.0
Am I missing something from my Dockerfile? Any help is appreciated as I feel like it’s something simple that I’m missing.
I tried adding EXPOSE 8888
and still received the same error. I also tried using pipx
and that failed to build the image in the first place. I reverted back to a Dockerfile (above) that was working a few weeks ago before I updated to Docker v4.34.2.
2
Answers
I took the advice above from David Maze and after a couple iterations this Dockerfile executes as intended:
The change was
--ip 0.0.0.0
to--ip=0.0.0.0
and--port 8888
to--port=8888
Dockerfile
/home/jupyter
to/jupyter
/home/jupyter
is for userjupyter
‘s home directory.but you run app by
root
, then I change directory to/jupyter
/home/jupyter/notebooks
to/jupyter/notebook
(
notebooks
tonotebook
)runit.sh
CMD
runit.sh
build
run
/jupyter/notebooks
to/jupyter/notebook