Great question!
Actually, the CMD in the Dockerfile is overridden by BinderHub when run that way. So the relevant line is actually from entrypoint.sh:
I’ll work on a simplified version of this command.
Let’s say that the underlying service will be:
streamlit hello --server.port 8506
You might attempt to run jhsingle-native-proxy like this:
jhsingle-native-proxy --destport 8506 --port 8888 streamlit hello --server.port {port}
Where {port} will be substituted as 8506 by jhsingle-native-proxy when it runs the command.
That doesn’t work because jhsingle-native-proxy thinks that --server.port {port} is intended for an argument for jhsingle-native-proxy rather than its underlying command. It will say that --server.port is not a valid option.
So the usual solution is a double dash to signify the end of arguments and start of the command:
jhsingle-native-proxy --destport 8506 --port 8888 -- streamlit hello --server.port {port}
That works fine.
BUT when JupyterHub attempts to run jupyter notebook, it appends a --port argument to the very end of the command it runs. Really jhsingle-native-proxy needs to pick that up as its own argument, but it appears to be intended for the underlying streamlit command.
So the solution instead is that {–} is simply substituted with – to inform jhsingle-native-proxy to pass it on to the underlying command. Any further --options (without {–}) may still be picked up by jhsingle-native-proxy itself.
Thus, this will work and be equivalent to the previous one above, but --port is allowed to come at the end and still be picked up by jhsingle-native-proxy rather than passed on to the underlying command:
jhsingle-native-proxy --destport 8506 streamlit hello {--}server.port {port} --port 8888
This tells jhsingle-native-proxy that we want a destport of 8506, and an incoming port of 8888. So requests to 8888 will be proxied to port 8506, and the process that we hope to receive those will be run as: streamlit hello --server.port 8506
I hope that makes sense - maybe I can bring some of this into the readme…