• Troels Schwarz-Linnet's avatar
    This is to fix running SUDO as eihter the jovyan user or root. · 0766b5f0
    Troels Schwarz-Linnet authored
    Please refer to alias, in bottom of commit.
    
    > dbn
    Execute the command: jupyter notebook
    
    > dbn bash
    jovyan@eedcc93a837d:~$
    
    > dbn start.sh
    Execute the command:
    exit
    
    > dbnr
    Set username to: jovyan
    usermod: no changes
    Set jovyan GID to: 100
    Execute the command: jupyter notebook
    Running as root is not recommended. Use --allow-root to bypass.
    exit
    
    > dbnr bash
    root@893cb78b8c9c:~#
    
    > dbnr start.sh
    Set username to: jovyan
    usermod: no changes
    Set jovyan GID to: 100
    Execute the command:
    No arguments supplied
    HOSTNAME=d45c52e788b7
    TERM=xterm
    SHELL=/bin/bash
    NB_USER=jovyan
    LC_ALL=en_US.UTF-8
    PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    _=/usr/bin/env
    MINICONDA_VERSION=4.3.30
    PWD=/home/jovyan
    LANG=en_US.UTF-8
    HOME=/home/jovyan
    SHLVL=2
    LANGUAGE=en_US.UTF-8
    no_proxy=*.local, 169.254/16
    DEBIAN_FRONTEND=noninteractive
    CONDA_DIR=/opt/conda
    NB_GID=100
    NB_UID=1000
    root@d45c52e788b7:~#
    
    > dbnrs
    Set username to: jovyan
    usermod: no changes
    Set jovyan GID to: 100
    Granting jovyan sudo access
    Execute the command: jupyter notebook
    Copy/paste this URL into your browser when you connect for the first time, ....
    
    > dbnrs bash
    root@f293dce949db:~#
    
    > dbnrs start.sh
    Set username to: jovyan
    usermod: no changes
    Set jovyan GID to: 100
    Granting jovyan sudo access
    Execute the command:
    No arguments supplied
    HOSTNAME=d0cd57ea32e2
    SHELL=/bin/bash
    TERM=xterm
    LC_ALL=en_US.UTF-8
    USER=jovyan
    SUDO_USER=root
    SUDO_UID=0
    USERNAME=jovyan
    MAIL=/var/mail/jovyan
    PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
    PWD=/home/jovyan
    LANG=en_US.UTF-8
    SHLVL=1
    SUDO_COMMAND=/bin/bash -c env; PATH=$PATH; bash
    HOME=/home/jovyan
    LANGUAGE=en_US.UTF-8
    LOGNAME=jovyan
    SUDO_GID=0
    _=/usr/bin/env
    jovyan@d0cd57ea32e2:~$
    
    > dbns
    Container must be run as root to grant sudo permissions
    Execute the command: jupyter notebook
    Copy/paste this URL in..
    
    > dbns bash
    jovyan@ce5c2491fa32:~$
    
    > dbns start.sh
    Container must be run as root to grant sudo permissions
    Execute the command:
    exit
    
    ###### Build user setup
    docker build -t $USER/base-notebook -f Dockerfile .
    
    # Normal, dbn: docker-base-notebook
    alias dbn='docker run -ti --rm -p 8888:8888 -v "$PWD":/home/jovyan/work --name base-notebook $USER/base-notebook'
    # Root, dbnr: dbn with root
    alias dbnr='docker run -ti --rm -p 8888:8888 --user root -v "$PWD":/home/jovyan/work --name base-notebook $USER/base-notebook'
    # Jovyan SUDO, dbnr: dbn with SUDO for jovyan
    alias dbnrs='docker run -ti --rm -p 8888:8888 --user root -e GRANT_SUDO=yes -v "$PWD":/home/jovyan/work --name base-notebook $USER/base-notebook'
    # Root, fail to sudo for jovyan.
    alias dbns='docker run -ti --rm -p 8888:8888 -e GRANT_SUDO=yes -v "$PWD":/home/jovyan/work --name base-notebook $USER/base-notebook'
    0766b5f0
start.sh 2.56 KB