뚝딱뚝딱

도커로 BeakerX 설치 후 볼륨 마운트 및 암호 설정

산도야지 2019. 7. 13. 17:52

왜 그리고 소감

자바를 다시 한 번 흝어봐야 할 필요가 생겨서, 일하는 중간 중간 연습해보려 했지만, 회사 보안 때문에 깃헙 푸시를 못함.

Gitpod, 구름IDE, 구글 collaboratory, repl 등등을 테스트 해보다가 지쳐버렸다. IDE 켜서 프로젝트 만드는 것도 귀찮고 런 버튼 누르거나 직접 컴파일 하는 것도 너모나 싫어짐.

jupyter 노트북 깔아서 코드 작성하고 해당 파일은 gitpod 으로 수동 싱크하기로 생각.

흠, 실습하기에는 괜찮네.

어떻게

준비

  • 윈도우 10 프로페셔널 설치

설치

  • 도커 포 윈도우즈
  • 카이트매틱
  • 비커엑스 컨테이너 설치

설정

0. 마운트할 볼륨 설정

윈도우에서는 볼륨 마운트 하려면 미리 설정해줘야 함.

1. 노트를 저장할 폴더 생성

나 같은 경우는 깃헙 저장소 떠서 클론해 둠.

C:\Users\jihoon\IdeaProjects\learnjava
c:/Users/jihoon/IdeaProjects/learnjava

2. 컨테이너 생성

  • 카이트매틱에서는 볼륨 추가가 할 수 없고

  • 호스트 이름 이상하면 접속할 때 불편함

    다음과 같이 수동으로 컨테이너 생성

    docker run -d --name beakerx -p 8888:8888 -v c:/Users/jihoon/IdeaProjects/learnjava:/home/beakerx/learnjava beakerx/beakerx

    -d 백그라운드에서 실행
    --name 컨테이너이름 설정
    -v 호스트디렉토리:대응되는컨테이너디렉토리 형식으로 마운트

    디렉토리 계층 구분자주의
    윈도우는 \ 리눅스는 /
    윈도 C:\Users\jihoon\IdeaProjects\learnjava
    리눅 c:/Users/jihoon/IdeaProjects/learnjava

아, 방화벽 때문에 호스트 폴더를 공유할 수없다.

컨테이너 날아가도 persist 할 저장소를 만들고

docker volume create --name DataVolume1

해당 저장소를 마운트 해준다

docker run -d --name beakerx --hostname localhost -p 8888:8888 -v DataVolume1:/home/beakerx/learnjava beakerx/beakerx

컨테이너 내부에서 디렉토리 생성이나.. 여튼 뭘 하고 싶으면 root 사용자로 로그인 해야함.

docker run -d --name beakerx --user root --hostname localhost -p 8888:8888 -v LeranJava:/home/beakerx/learnjava beakerx/beakerx

beakerx 에서 해당 디렉토리 쓰기/읽기/지우기 등 하게 해주려면 권한 낮추기

chmod +777 디렉토리명

3. 암호 설정

컨테이너 exec 버튼 눌러서 쉘 켠다음, 다음 명령어 실행하면 된다.

beakerx@localhost:~/$cd /opt/conda/envs/beakerx/bin
beakerx@localhost:/opt/conda/envs/beakerx/bin$ ./ipython
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from IPython.lib import passwd

In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:어떤키'

In [3]: 컨트롤 + D 눌러서 나가기
Do you really want to exit ([y]/n)? y

확인하면 암호가 들어가 있다.

beakerx@localhost:/opt/conda/envs/beakerx/bin$ cd ~/.jupyter
beakerx@localhost:~/.jupyter$ gedit
bash: gedit: command not found
beakerx@localhost:~/.jupyter$ cat jupyter_notebook_config.json
{
  "NotebookApp": {
    "password": "sha1:다른어떤키"
  }
}beakerx@localhost:~/.jupyter$ ls
beakerx.json  jupyter_notebook_config.json
beakerx@localhost:~/.jupyter$

컨테이너 재 기동하면, 아래처럼 암호만 입력하란 화면이 나옴.

오류 발생


아 귀찮다. 귀찮어. 암호 설정하면 파일이 만들어 지는 데, 이거 쓸 수가 없다고 오류난다.

컨테이너 새로 만들고, 암호 설정하는 거 안함.


FileNotFoundError: [Errno 2] No such file or directory: '/home/beakerx/.jupyter/jupyter_notebook_config.json'

[I 01:06:56.211 NotebookApp] Creating new directory in /learnjava/headfirstJavaExercise
[W 01:06:56.211 NotebookApp] 403 POST /api/contents/learnjava/headfirstJavaExercise (172.17.0.1): Permission denied: learnjava/headfirstJavaExercise/Untitled Folder
[W 01:06:56.212 NotebookApp] Permission denied: learnjava/headfirstJavaExercise/Untitled Folder
[I 01:07:32.963 NotebookApp] Creating new directory in /learnjava/headfirstJavaExercise
[W 01:32:41.552 NotebookApp] delete /learnjava/headfirstjavaexercise.git
[W 01:32:41.553 NotebookApp] Skipping trash for /home/beakerx/learnjava/headfirstjavaexercise.git, on different device to home directory
[W 01:32:41.554 NotebookApp] 400 DELETE /api/contents/learnjava/headfirstjavaexercise.git (172.17.0.1): Directory /home/beakerx/learnjava/headfirstjavaexercise.git not empty
[W 01:32:41.554 NotebookApp] Directory /home/beakerx/learnjava/headfirstjavaexercise.git not empty
[W 01:32:41.556 NotebookApp] delete /learnjava/hf.git
[W 01:32:41.556 NotebookApp] Skipping trash for /home/beakerx/learnjava/hf.git, on different device to home directory
[W 01:32:41.556 NotebookApp] 400 DELETE /api/contents/learnjava/hf.git (172.17.0.1): Directory /home/beakerx/learnjava/hf.git not empty
[W 01:32:41.556 NotebookApp] Directory /home/beakerx/learnjava/hf.git not empty
[W 01:32:41.559 NotebookApp] delete /learnjava/test.git
[W 01:32:41.559 NotebookApp] Skipping trash for /home/beakerx/learnjava/test.git, on different device to home directory
[W 01:32:41.559 NotebookApp] 400 DELETE /api/contents/learnjava/test.git (172.17.0.1): Directory /home/beakerx/learnjava/test.git not empty
[W 01:32:41.560 NotebookApp] Directory /home/beakerx/learnjava/test.git not empty
[I 01:35:09.224 NotebookApp] Wrote hashed password to /home/beakerx/.jupyter/jupyter_notebook_config.json

/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))

Session terminated, terminating shell...[C 00:03:30.533 NotebookApp] received signal 15, stopping
[I 00:03:30.535 NotebookApp] Shutting down 9 kernels
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
/opt/conda/envs/beakerx/lib/python3.6/site-packages/IPython/paths.py:61: UserWarning: IPython dir '/home/beakerx/.ipython' is not a writable location, using a temp directory.
  " using a temp directory.".format(ipdir))
[I 00:03:31.349 NotebookApp] Kernel shutdown: 4a049a4c-4891-4ecc-ae00-f8c35b6a497c
[I 00:03:31.350 NotebookApp] Kernel shutdown: c917c4b6-3125-4908-b107-65fc55cba764
[I 00:03:31.350 NotebookApp] Kernel shutdown: 4ba53aa8-b9db-4653-8b90-48ffd5e3a58f
[I 00:03:31.350 NotebookApp] Kernel shutdown: 0728d619-8e28-41cf-9311-0e23b28d4840
[I 00:03:31.350 NotebookApp] Kernel shutdown: 593732a5-98e1-4d03-bdd9-9f39e6dcaa2b
[I 00:03:31.351 NotebookApp] Kernel shutdown: 3dc75604-1e4c-404a-9f70-d706e409effc
[I 00:03:31.351 NotebookApp] Kernel shutdown: d401a189-d7fd-4bc4-b9c2-a67b71851968
[I 00:03:31.352 NotebookApp] Kernel shutdown: e8b912fa-33f1-4d4e-b823-86e5a16e94a8
[I 00:03:32.757 NotebookApp] Kernel shutdown: 0eb42f16-1664-4e3a-95c6-e69c9f907d62
 ...waiting for child to terminate.