Commit cdc9e85c by Liang-Chi Hsieh Committed by Tianqi Chen

Use bridge network and expose port on macOS when launch docker image (#3086)

parent 1e84d04c
......@@ -35,7 +35,13 @@ DOCKER_IMAGE_NAME=("$1")
if [ "$#" -eq 1 ]; then
COMMAND="bash"
CI_DOCKER_EXTRA_PARAMS=("-it --net=host")
if [[ $(uname) == "Darwin" ]]; then
# Docker's host networking driver isn't supported on macOS.
# Use default bridge network and expose port for jupyter notebook.
CI_DOCKER_EXTRA_PARAMS=("-it -p 8888:8888")
else
CI_DOCKER_EXTRA_PARAMS=("-it --net=host")
fi
else
shift 1
COMMAND=("$@")
......
......@@ -46,7 +46,8 @@ This auxiliary script does the following things:
- Mount current directory to /workspace
- Switch user to be the same user that calls the bash.sh (so you can read/write host system)
- Use the host-side network (so you can use jupyter notebook)
- Use the host-side network on Linux. Use the bridge network and expose port 8888 on macOS,
because host networking driver isn't supported. (so you can use jupyter notebook)
Then you can start a jupyter notebook by typing
......@@ -55,6 +56,16 @@ Then you can start a jupyter notebook by typing
jupyter notebook
You might see an error ``OSError: [Errno 99] Cannot assign requested address`` when starting
a jupyter notebook on macOS. You can change the binding IP address by
.. code:: bash
jupyter notebook --ip=0.0.0.0
Note that on macOS, because we use bridge network, jupyter notebook will be reportedly running
at an URL like ``http://{container_hostname}:8888/?token=...``. You should replace the ``container_hostname``
with ``localhost`` when pasting it into browser.
Docker Source
-------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment