Docker

Docker Project 2-Docker, Jupyternotebook

Naranjito 2021. 11. 12. 11:06

1. Create Dockerfile to run Jupyternotebook.

FROM continuumio/miniconda3
  
WORKDIR /usr/app

RUN mkdir result

RUN mkdir src

EXPOSE 8888 #Allow to access to container port

RUN pip install --no-cache-dir --upgrade pip

COPY ./requirements.txt .

RUN pip install -r requirements.txt

RUN pip install jupyter

RUN jupyter notebook --generate-config --allow-root

ENTRYPOINT jupyter notebook --allow-root --ip=0.0.0.0 --port=8888 --no-browser #Execute jupyter notebook when start container

 

2. Docker build

$ docker build -t jupyter:1.0 .

 

3. Mount local directory with container using volume. DO NOT FORGET TO CONNECT PORT(I made mistake one time when I connect to jupyter, I didn't connect the port).

$ docker run -it --rm -p 8888:8888 --name jupyter -v /Users/joohyunyoon/Documents/Workspace/src:/usr/app/src jupyter:1.0

...

http://139c0b0ad9e7:8888/?token=fcc3dce70ca9d4c58c7ecb54f0dbbb0b10cc2d45a960dc9d
     or http://127.0.0.1:8888/?token=fcc3dce70ca9d4c58c7ecb54f0dbbb0b10cc2d45a960dc9d
     
...

 

4. Access Jupyternotebook on the browser.

 

5. Access Jupyternotebook on VisualStuioCode and check the volume.

When code has change whether Jupyternotebook or VisualStuioCode, it interacts well.

- Jupyternotebook

- VisualStuioCode