Skip to content

Instantly share code, notes, and snippets.

@mjkloeckner
Last active September 11, 2024 16:25

Revisions

  1. mjkloeckner revised this gist Sep 11, 2024. 1 changed file with 22 additions and 2 deletions.
    24 changes: 22 additions & 2 deletions run-jupyter
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,27 @@
    systemctl is-active --quiet docker || systemctl start docker
    systemctl is-active --quiet containerd || systemctl start containerd

    PORT=8888

    # if port in use increment port number until port number is available
    while $(nc -vz 127.0.0.1 $PORT >/dev/null 2>&1)
    do
    PORT=$((PORT + 1))
    done

    test -e "$HOME"/.jupyter || mkdir "$HOME"/.jupyter

    docker run \
    -p 8888:8888 \
    -it --rm \
    -p $PORT:8888 \
    -e DOCKER_STACKS_JUPYTER_CMD=notebook \
    -v "${PWD}":/home/jovyan/work jupyter/datascience-notebook
    -e JUPYTERLAB_ENABLED=false \
    -v "${PWD}":/home/jovyan/work \
    -v "$HOME"/.jupyter/:/home/jovyan/.jupyter \
    -d jupyter/datascience-notebook \
    start-notebook.py --NotebookApp.token='' --custom-css

    test $? -eq 0 && CONTAINER_NAME="$(docker ps -l --format "{{.Names}}")"

    echo "Running on container '$CONTAINER_NAME' with address: http://localhost:$PORT"
    sleep 3 && explorer.exe "http://localhost:$PORT" >/dev/null 2>&1 &
  2. mjkloeckner revised this gist Aug 31, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion run-jupyter
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/sh

    # https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html
    # https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html#alternative-commands
    # https://docs.docker.com/reference/cli/docker/container/exec/

    systemctl is-active --quiet docker || systemctl start docker
    systemctl is-active --quiet containerd || systemctl start containerd
  3. mjkloeckner revised this gist Aug 31, 2024. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions run-jupyter
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    #!/bin/sh

    # https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html
    # https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html#alternative-commands

    systemctl is-active --quiet docker || systemctl start docker
    systemctl is-active --quiet containerd || systemctl start containerd

  4. mjkloeckner created this gist Aug 31, 2024.
    9 changes: 9 additions & 0 deletions run-jupyter
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #!/bin/sh

    systemctl is-active --quiet docker || systemctl start docker
    systemctl is-active --quiet containerd || systemctl start containerd

    docker run \
    -p 8888:8888 \
    -e DOCKER_STACKS_JUPYTER_CMD=notebook \
    -v "${PWD}":/home/jovyan/work jupyter/datascience-notebook