1.利用dockerfile构建anaconda开发环境
1.dockerfile如下
FROM continuumio/anaconda3
RUN true \
# debian china mirrors
&& sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
&& sed -i 's/security.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list \
# timezone to china
&& ln -sf /usr/share/zoneinfo/PRC /etc/localtime
RUN rm -rf /opt/conda/envs
COPY /anaconda/env /opt/conda/envs
COPY /anaconda/data/jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
VOLUME /data
WORKDIR /data
EXPOSE 8888
ENTRYPOINT /opt/conda/envs/env2/bin/jupyter lab --ip='*' --port=8888 --no-browser --allow-root
注:/data为登录目录 ,jupyter_notebook_config.py为密钥,envs中为python环境
2.其中密钥生成
jupyter notebook --generate-config
生成的配置文件位置为:~/.jupyter/jupyter_notebook_config.py
打开jupyter,新建一个notebook,创建密码以及生成密码的sha1密钥,所需代码如下:
from notebook.auth import passwd
passwd()
输入一遍你想设置的密码,然后再输入一遍确认,记录下生成的sha1密钥值。形式如:‘sha1:xxxxxxx’
修改config文件中的“xxx”
c.NotebookApp.password ='argon2:$argon2id$v=19$m=10240,t=10,p=xxx'
重启jupyter,密码生效。