본문 바로가기
Development/Docker

[Docker] 컨테이너의 Jupyter Notebook 기본 Shell을 bash로 변경 및 설정하는 방법

by 성딱이 2022. 5. 10.
반응형
방법 1. Build단계에서 미리 설정
FROM tensorflow/tensorflow:2.5.1-gpu

RUN apt-key del 7fa2af80 \
&& apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/3bf863cc.pub \
&& apt-get update -y && apt-get install -y build-essential \
        tmux \
        vim \
&& pip install --upgrade pip && pip install matplotlib \
        pandas \
        numpy \
        pymysql \
        jupyter \
        scipy \
&& jupyter notebook --generate-config \
&& echo $'\
# from IPython.lib import passwd \n\
# password = passwd("Wink")\n\
# c.NotebookApp.password=password \n\

# 이부분이다!!!
c.NotebookApp.terminado_settings = { "shell_command": ["/bin/bash"] }' \
>> /root/.jupyter/jupyter_notebook_config.py

SHELL ["/bin/bash", "-c"]
# RUN ["/bin/bash", "-ec", "yap"]

 

방법 2. 컨테이너 생성 후 설정 
$ vim ~/.jupyter/jupyter_notebook_config.py

# 해당 소스코드 추가
c.NotebookApp.terminado_settings = { "shell_command": ["/bin/bash"] }

 

방법 3. (+α) Jupyter의 Shell이 아닌 로컬(Ubuntu 20.04)에서의 Shell 변경하는 방법
# 1. 현재 사용하고 있는 Shell 종류 확인
\[\e]0;\u@\h: \w\a\]\u@\h:\w$ echo $SHELL


# 2. 사용가능한 Shell의 종류 확인
\[\e]0;\u@\h: \w\a\]\u@\h:\w$ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dash
/usr/bin/tmux


# 3. 기본 Shell을 Bash Shell로 설정
\[\e]0;\u@\h: \w\a\]\u@\h:\w$ chsh -s /bin/bash
\[\e]0;\u@\h: \w\a\]\u@\h:\w$ bash

________                               _______________
___  __/__________________________________  ____/__  /________      __
__  /  _  _ \_  __ \_  ___/  __ \_  ___/_  /_   __  /_  __ \_ | /| / /
_  /   /  __/  / / /(__  )/ /_/ /  /   _  __/   _  / / /_/ /_ |/ |/ /
/_/    \___//_/ /_//____/ \____//_/    /_/      /_/  \____/____/|__/


WARNING: You are running this container as root, which can cause new files in
mounted volumes to be created as the root user on your host machine.

To avoid this, run the container by specifying your users userid:

$ docker run -u $(id -u):$(id -g) args...

root@81de83479ec2:/home/JH # echo $SHELL
/bin/bash

 

 

 

출처 1 : https://github.com/moby/moby/issues/7281

출처 2 : https://wiki.ubuntu.com/ChangingShells

출처 3 : https://www.linuxuprising.com/2021/01/how-to-change-default-shell-in-linux.html

출처 4 : https://discourse.jupyter.org/t/customizing-shell-launched-by-terminal/3412

 

 

 

 

 

반응형

댓글