Added some Dockerfiles
optimized the directory structure
This commit is contained in:
parent
6fa0951813
commit
93b7643e3b
@ -1,14 +1,17 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
RUN cp /etc/apt/sources.list /etc/apt/sources.list.ori && \
|
||||
sed -i s@/archive.ubuntu.com/@/mirrors.ustc.edu.cn/@g /etc/apt/sources.list && \
|
||||
sed -i s@/security.ubuntu.com/@/mirrors.ustc.edu.cn/@g /etc/apt/sources.list && \
|
||||
apt clean
|
||||
apt clean &&\
|
||||
mkdir /jupyter &&\
|
||||
groupadd notebook &&\
|
||||
useradd -m -s /bin/bash -G notebook notebooks &&\
|
||||
usermod -aG sudo notebooks &&\
|
||||
chown -R notebooks:notebook /jupyter
|
||||
RUN apt update && apt install -y python3 python3-pip
|
||||
RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter
|
||||
RUN jupyter notebook --generate-config
|
||||
RUN apt install -y wget
|
||||
RUN rm /root/.jupyter/jupyter_notebook_config.py && mkdir /jupyter
|
||||
WORKDIR /root/.jupyter/
|
||||
RUN wget http://www.americas.asia/cdn/docker/jupyter/jupyter_notebook_config.py -O ./jupyter_notebook_config.py
|
||||
RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyterlab
|
||||
|
||||
EXPOSE 8888
|
||||
CMD ["jupyter", "notebook", "--allow-root"]
|
||||
USER notebooks
|
||||
CMD ["jupyter", "lab", "--no-browser", "--ip", "\"0.0.0.0\"", "--port", "8888", "--allow-root"]
|
||||
28
Jupyter Notebook/Alpine-NonRoot/Dockerfile
Normal file
28
Jupyter Notebook/Alpine-NonRoot/Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
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 && \
|
||||
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter --no-cache-dir && \
|
||||
apk del libc-dev libffi-dev gcc &&\
|
||||
addgroup notebook &&\
|
||||
adduser -Ss /bin/nologin -g notebook notebook &&\
|
||||
chown -R notebook:notebook . &&\
|
||||
mkdir /data &&\
|
||||
chown -R notebook:notebook /data
|
||||
RUN \
|
||||
jupyter notebook --generate-config &&\
|
||||
mkdir ./config &&\
|
||||
cp /root/.jupyter/jupyter_notebook_config.py ./config
|
||||
|
||||
RUN \
|
||||
sed -i.bak 's/# c.NotebookApp.ip = .*/c.NotebookApp.ip = '\''0.0.0.0'\''/' ~/.jupyter/jupyter_notebook_config.py && \
|
||||
sed -i.bak 's/# c.NotebookApp.notebook_dir = .*/c.NotebookApp.notebook_dir = '\''\/data'\''/' ~/.jupyter/jupyter_notebook_config.py
|
||||
|
||||
EXPOSE 8888
|
||||
USER notebook
|
||||
CMD [ "jupyter", "notebook", "--config=", "\"/jupyter/config\"" ]
|
||||
20
Jupyter Notebook/Alpine-Root/Dockerfile
Normal file
20
Jupyter Notebook/Alpine-Root/Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
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 && \
|
||||
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter --no-cache-dir && \
|
||||
apk del libc-dev libffi-dev gcc
|
||||
RUN \
|
||||
jupyter notebook --generate-config &&\
|
||||
mkdir /data &&\
|
||||
sed -i.bak 's/# c.NotebookApp.ip = .*/c.NotebookApp.ip = '\''0.0.0.0'\''/' /root/.jupyter/jupyter_notebook_config.py && \
|
||||
sed -i.bak 's/# c.NotebookApp.notebook_dir = .*/c.NotebookApp.notebook_dir = '\''\/data'\''/' /root/.jupyter/jupyter_notebook_config.py
|
||||
|
||||
EXPOSE 8888
|
||||
USER root
|
||||
CMD [ "jupyter", "notebook", "--allow-root" ]
|
||||
11
README
11
README
@ -1,3 +1,4 @@
|
||||
Before building the image, please switch the working directory to the directory where the corresponding version Dockerfile resides
|
||||
build image by shell:
|
||||
docker build -t <author>/jupyter:<tag>
|
||||
|
||||
@ -7,4 +8,12 @@ docker volume create jupyter
|
||||
docker run -itd --name jupyter -p 8888:8888 -v jupyter:/jupyter <author>/jupyter:<tag>
|
||||
|
||||
- Second Method
|
||||
docker run -itd --name jupyter -p 8888:8888 -v /path/to/save:/jupyter <author>/jupyter:<tag>
|
||||
docker run -itd --name jupyter -p 8888:8888 -v /path/to/save:/jupyter <author>/jupyter:<tag>
|
||||
|
||||
Version
|
||||
------
|
||||
Jupyter Lab:
|
||||
- / : Jupyter Lab servers built on Ubuntu, run as non-root users.
|
||||
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.
|
||||
Loading…
x
Reference in New Issue
Block a user