Docker

[Docker] Jupyter/datascience-notebook 구축 하기

IT-PAPA 2023. 2. 21. 06:30
728x90
반응형

필자는 python 에도 관심이 있기 때문에 jupyter 같은 컨테이너 서비스를 좋아한다.
왜냐하면, 소스 코드 쓰는 데로 바로 결과를 확인할 수 있기 때문이다.
파이썬에 관심이 많다면 해당 서비스를 사용해 보길 추천한다.

docker-compose.yml 파일

docker-compose.yml
version: "3"
services:
  datascience-notebook:
      image: jupyter/datascience-notebook
      volumes:
        - ./docker_repository/jupyter:/home/jovyan/work
      ports:
        - 8800:8888
      environment:
        - GRANT_SUDO=yes
      container_name: jupyter-container

 

docker-compose 시작

docker-compose up -d

# root 계정으로 서비스 올리고 싶을 경우
docker run --name jupyter-container -e GRANT_SUDO=yes --user root -p 8800:8888 -d -it jupyter/datascience-notebook
master@master:~/docker2/docker/docker/jupyter$ docker-compose up -d
Creating network "jupyter_default" with the default driver
Pulling datascience-notebook (jupyter/datascience-notebook:)...
latest: Pulling from jupyter/datascience-notebook
6e3729cf69e0: Pull complete
2a5593e5ecfc: Pull complete
20992337f1f4: Pull complete
4f4fb700ef54: Pull complete
1251f2e2dce2: Pull complete
47ab07aa15a9: Pull complete
3e9d8e201824: Pull complete
02a2fc3dea5e: Pull complete
70dcc59aa209: Pull complete
8136769236d4: Pull complete
14c799efb5eb: Pull complete
090e64dba0d9: Pull complete
5690d470bf80: Pull complete
01c98906b370: Pull complete
a2b861f1f8bd: Pull complete
30008ac36da9: Pull complete
b83a4840ce73: Pull complete
baef5752be62: Pull complete
7158b286e056: Pull complete
8cc9f159a8d7: Pull complete
2da8e9a66547: Pull complete
5948d29dccd8: Pull complete
cbb4a7bcbf00: Pull complete
aed48a9fd8d4: Pull complete
a5b53536dee1: Pull complete
42aa8bfd227a: Pull complete
325e500204b1: Pull complete
813081653b3a: Pull complete
Digest: sha256:8f9315f712f1b1d65ee47b37421c4c343edcea538536125898536602ccc6617a
Status: Downloaded newer image for jupyter/datascience-notebook:latest
Creating jupyter-container ... done

portainer jupyter 서비스 확인
portainer jupyter 서비스 확인

 

Jupyter notebook Container 실행

docker exec -it jupyter-container bash

 

Jupyter notebook 비밀번호 생성

ipython

>> from notebook.auth import passwd
>> passwd()
>> 비밀번호 입력
>> 비밀번호 재입력
# 출력된 비밀번호를 저장
>> exit
(base) root@398e519a2beb:~# ipython
Python 3.10.9 | packaged by conda-forge | (main, Feb  2 2023, 20:20:04) [GCC 11.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.9.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: 
Verify password: 
Out[3]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$3bbxoPpRJ8ILTerJ9oPtkA$7HzPPtXgExCAsnVv4KPS3UVSlFAfzqchVNCYV9Urpzs'

In [4]: exit

 

Jupyter notebook vim 설치

sudo apt-get update
sudo apt-get install vim -y
sudo vi ~/.jupyter/jupyter_notebook_config.py

 

jupyter_notebook_config.py 비밀번호 설정

c.NotebookApp.password_required = True
c.NotebookApp.password = '생성된 비밀번호 입력'

c.NotebookApp.password_required = True
c.NotebookApp.password_required = True
c.NotebookApp.password = '생성된 비밀번호 입력'
c.NotebookApp.password = '생성된 비밀번호 입력'

 

docker jupyter container 재부팅

docker restart jupyter-container

 

반응형

서비스 URL 접속

http://[서버 IP]:8800

서비스 URL 접속
서비스 URL 접속
jupyter main 화면
jupyter main 화면

 

docker-comopse 중지

docker-compose down

 

 

[Docker] 도커의 모든 것, 도커 추천 이미지!!! (tistory.com)

 

[Docker] 도커의 모든 것, 도커 추천 이미지!!!

필자는 이때까지 docker로 구축한 모든 목록을 이 블로그에 담았다. 앞으로도 이 페이지는 필자가 도커를 구축할 때마다 업데이트하려고 하니, 즐겨찾기 해두면 나쁘지 않을 거 같다. 유용하게 사

betwe.tistory.com

 

728x90
반응형
LIST