Currently, my workflow is to use an alias for the jupyter lab command via RUN echo 'alias...'
at the end of my Dockerfile:
RUN echo 'alias jupyterlab="jupyter lab --ip=0.0.0.0 --port=8117 --no-browser --allow-root"' >> ~/.bashrc
which enables me to open up the JupyterLab container in my browser at port-number 8117, using just the command jupyterlab
.
I would like to try to generalise this so that any valid port_number
can be submitted as a build argument when building the Dockerfile, via e.g.,
docker build -t <image_name> . --build-arg PORTNUM=<port_number>
by changing the Dockerfile. Since Bash alias
doesn't take arguments, I tried to adapt this solution:
RUN echo 'jupyterlab() { jupyter lab --ip=0.0.0.0 --port="$PORTNUM" --no-browser --allow-root ; }' >> ~/.bashrc
but now I get error
traitlets.traitlets.TraitError: The 'port' trait of a ServerApp instance must be an int, but a value of '' <class 'str'> was specified.
which suggests that no argument ended up being passed to the $PORTNUM. Anyone know how to fix this?