support jupyter lab build in alpine linux

This commit is contained in:
set 2023-10-22 22:59:42 +08:00
parent 93b7643e3b
commit 2f772b50f8
3 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,23 @@
FROM python:3-alpine
LABEL maintainer="<author>"
LABEL version="selfbuilt"
WORKDIR /jupyter
RUN \
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories &&\
apk add --no-cache libc-dev libffi-dev gcc sudo && \
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyterlab --no-cache-dir && \
apk del libc-dev libffi-dev gcc
RUN \
addgroup notebook &&\
adduser -Ss /bin/bash -g notebook notebook &&\
adduser notebook sudo &&\
echo "notebook:123456" | chpasswd &&\
chown -R notebook:notebook . &&\
mkdir /data &&\
chown -R notebook:notebook /data
EXPOSE 8888
USER notebook
CMD ["jupyter", "lab", "--no-browser", "--ip", "\"0.0.0.0\"", "--port", "8888", "--allow-root"]

View File

@ -8,8 +8,9 @@ RUN cp /etc/apt/sources.list /etc/apt/sources.list.ori && \
groupadd notebook &&\
useradd -m -s /bin/bash -G notebook notebooks &&\
usermod -aG sudo notebooks &&\
echo 'notebooks:123456' | chpasswd &&\
chown -R notebooks:notebook /jupyter
RUN apt update && apt install -y python3 python3-pip
RUN apt update && apt install -y python3 python3-pip sudo
RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyterlab
EXPOSE 8888

3
README
View File

@ -13,7 +13,8 @@ docker run -itd --name jupyter -p 8888:8888 -v /path/to/save:/jupyter <author>/j
Version
------
Jupyter Lab:
- / : Jupyter Lab servers built on Ubuntu, run as non-root users.
- /Alpine-NonRoot : Jupyter Lab server built on Alpine Linux, running with non-root users (`notebook`), this build is relatively secure.
- /Ubuntu2204-NonRoot : Jupyter Lab server built on Ubuntu 22.04, running with non-root users (`notebook`), this build is relatively secure.
Jupyter Notebook:
- /Alpine-NonRoot : Jupyter Notebook server built on Alpine Linux, running with non-root users (`notebook`), this build is relatively secure.
- /Alpine-Root : Jupyter Notebook server built on Alpine Linux, running as Root user, this build is recommended only for testing or learning environments deployed on an Intranet.