镜像制作
(1)Dockerfile编写
FROM python:3.9.16 RUN python -m pip install --upgrade pip RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple RUN pip install numpy RUN pip install pandas RUN pip install matplotlib RUN pip install requests RUN pip install flask RUN pip install pysqlcipher3 RUN pip install PyMySQL RUN pip install SQLAlchemy # 创建用户 RUN useradd -ms /bin/bash notebook # 设置默认目录 RUN pip install jupyterlab RUN jupyter-lab --generate-config RUN echo "c.NotebookApp.notebook_dir='/opt/notebook'" >> /root/.jupyter/jupyter_lab_config.py EXPOSE 8888 CMD jupyter-lab --ip 0.0.0.0 --port 8888 --allow-root --no-browser
(2)Dockerfile构建命令
docker build -t jupyterlab:20241217 .
Docker基本命令
(1)查看镜像
docker images
(2)启动容器
docker run -p 8888:8888 jupyterlab:20241217
(3)停止容器(容器ID)
docker stop cdd3e79839eb
(4)删除容器
docker rm cdd3e79839eb
(5)删除镜像
docker rmi jupyterlab:20241217
(6)镜像保持到本地文件
docker save -o jupyterlab-20230718.tar jupyterlab:20230718
(7)镜像文件加载
docker load < jupyterlab-20230718.tar
启动jupyterlab
(1)启动容器
docker run -p 8888:8888 -v /opt/jupyter/notebook:/home/notebook -d jupyterlab:20230731
-d 表示后台运行
(2)进入容器
docker exec -it cdd3e79839eb /bin/bash
(3)获取jupyter的token命令
jupyter-lab list
评论