话不多说,上dockerfile
from alpine
RUN echo "http://mirrors.aliyun.com/alpine/v3.9/main/" > /etc/apk/repositories
RUN apk update
RUN apk upgrade
RUN apk add --no-cache python3 python3-dev gcc openssl-dev openssl libressl libc-dev linux-headers libffi-dev libxml2-dev libxml2 libxslt-dev g++
RUN mkdir /root/.pip && touch /root/.pip/pip.conf
RUN echo -e "[global] \n index-url = https://mirrors.aliyun.com/pypi/simple/" > /root/.pip/pip.conf
RUN pip3 install --upgrade pip
RUN pip install jupyter
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--no-browser", "--allow-root"]
其中包含更新alpine安装包下载源为国内阿里源,更新pip源为国内阿里源,更新pip版本,以及最终的jupyter启动
镜像构建完成之后,启动镜像。
docker run -it --rm -p 8888:8888 python:jupyter
复制?token=xxxxxxxxxxxxxxxxxx
最终访问url docker服务器IP:8888/?token=xxxxxxxxxxxxxxxxxxxxxxx