Docker JupyterLab local machine

Hello, this post is to explain how to prepare Docker image for JupyterLab

To install Anaconda is simple solution, but these days Anaconda is not free for commercial usage.

Actually, we don’t need Anaconda to use JupyterNotebook, JupyterLab, especially data analysis with Python.

Data science with JupyterLab
Run, develop, and share data science projects using JupyterLab and Docker

This article is one of good solution to prepare environment. But it is not minimum. Let I will prepare minimum environment

Prepare environment

  • Python3
  • Alpine Linux
  • JupyterLab

Only 3 are required.

Let’s prepare Dockerfile

FROM python:alpine3.21
RUN apk update && apk add \
        sudo \
        gcc \
        libc-dev =\
        linux-headers
RUN pip install -upgrade pip & pip install jupyterlab
CMD ["jupyter","lab","--ip=0.0.0.0","--allow-root","--LabApp.token=''"]

Base is python:alpine3.21

Install some commands (gcc and libc-dev, linux-headers are required to install jupyterlab)

Upgrade pip and install jupyterlab latest version.

Last part is jupyterlab command with no security token.

Build and Start Container

Let’s build

docker build .

Check image id

docker images

You can check docker image and keep it

docker run -p 8888:8888 -v <src>:/opt 7a725c853eec

This is an example of Docker run command. src part is your local machine folder. You can mount this into /opt, 7a725c853eec is docker image id from docker images command.

You can access jupyuterlab with http://localhost:8888

コメント

タイトルとURLをコピーしました