1. 主机运行jupyter容器

| #切换root用户,接下来的命令用root用户好操作 |
| sudo su |
| |
| #查看docker在线下载源 |
| docker info |
| |
| #配置docker在线下载源 |
| vi /etc/docker/daemon.json |
| { |
| "registry-mirrors":[ |
| "https://registry.docker-cn.com", |
| "http://hub-mirror.c.163.com", |
| "https://docker.mirrrors.ustc.edu.cn" |
| ] |
| } |
| 输入以上内容,保存退出,重启docker |
| service docker restart |
| |
| #查看docker状态 |
| systemctl status docker |
| |
| #启动docker |
| systemctl start docker |
| |
| #搜索alpine镜像 |
| docker search alpine |
| |
| #下载镜像 |
| docker pull alpine |
| |
| #查看镜像 |
| docker images |
| |
| #创建共享目录,可递归创建文件夹(-p) |
| mkdir -p /xx/mount |
| |
| #根据alpine镜像来创建容器 |
| docker create -it --name myalpine -h alpine --privileged=true -v /xx/mount:/xx/mount -p 9085:9085 alpine:latest /sbin/init |
| - `docker create`:创建一个新的容器 |
| - `-it`:以交互式 shell 模式运行容器,并将 stdin 开放给容器 |
| - `--name myalpine`:为容器指定一个名称为 myalpine |
| - `-h alpine`:指定容器的主机名为 alpine |
| - `--privileged=true`:以特权模式运行容器,可以访问所有设备和文件系统,逃避所有应用程序沙盒的限制 |
| - `-v /xx/mount:/xx/mount`:挂载本地主机上的目录 `/xx/mount` 到容器内的目录 `/xx/mount` |
| - `-p 9085:9085`:将主机端口 9085 映射到容器端口 9085,使得外部网络可以通过此端口访问容器内部应用程序 |
| - `alpine:latest`:使用最新版本的 Alpine 镜像作为基础镜像来创建容器 |
| - `/sbin/init`:在容器中执行 init 进程,启动系统初始化进程,并启动所有系统服务。 |
| |
| #查看创建的容器 |
| docker ps -a |
| |
| #启动容器 |
| docker start myalpine |
| |
| #查看运行的容器 |
| docker ps |
2. 进入jupyter容器
| |
| docker exec -it myalpine /bin/sh |
| |
| |
| vi /etc/apk/repositories //源配置文件 |
| https://mirrors.ustc.edu.cn/alpine/latest-stable/main |
| https://mirrors.ustc.edu.cn/alpine/latest-stable/community //注释旧源,写入新源 |
| apk update //更新新源 |
| |
| |
| apk add python3 python3-dev gcc openssl-dev openssl libressl libc-dev linux-headers libffi-dev libxml2-dev libxml2 libxslt-dev g++ |
| python3:安装Python3; |
| python3-dev:安装Python3开发工具; |
| gcc:安装GNU编译器; |
| openssl-dev:安装OpenSSL开发库; |
| openssl:安装OpenSSL库; |
| libressl:安装LibreSSL库; |
| libc-dev:安装C语言开发工具; |
| linux-headers:安装Linux内核头文件; |
| libffi-dev:安装Foreign Function Interface库的开发工具; |
| libxml2-dev:安装XML开发库; |
| libxml2:安装XML库; |
| libxslt-dev:安装Libxslt库的开发工具; |
| g++:安装C++编译器。 |
| |
| |
| vi /home/.pip/pip.conf |
| [global] |
| timeout=60 |
| index-url=http://pypi.douban.com/simple |
| extra-index-url=http://mirrors.aliyun.com/pypi/simple/ |
| https://pypi.tuna.tsinghua.edu.cn/simple/ |
| http://pypi.mirrors.ustc.edu.cn/simple/ |
| [install] |
| trusted-host=pypi.douban.com |
| mirrors.aliyun.com |
| pypi.tuna.tsinghua.edu.cn |
| pypi.mirrors.ustc.edu.cn |
| [freeze] |
| timeout = 10 |
| |
| |
| pip cache purge |
| |
| |
| pip config get global.index-url |
| |
| |
| pip3 install jupyter |
| |
| |
| python |
| from notebook.auth import passwd |
| passwd() |
| |
| |
| jupyter notebook --generate-config |
| 默认在~/.jupyter目录下会生成三个文件 |
| jupyter_notebook_config.py |
| migrated |
| nbconfig |
| |
| |
| vi ~/.jupyter/jupyter_notebook_config.py |
| c.NotebookApp.ip='*' |
| c.NotebookApp.password = u'sha1:xxx' |
| c.NotebookApp.open_browser = False |
| c.NotebookApp.port =9085 |
| |
| |
| pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install --sys-prefix |
| |
| |
| |
| |
| jupyter notebook --notebook-dir=/xx/mount --allow-root > /xx/mount/jupyter.log 2>&1 & |
| |
| |
| pgrep jupyter |
| |
| |
| pkill -9 jupyter |
3. 退出jupyter容器
| |
| exit |
| |
| |
| cd /xx/mount |
| |
| |
| git clone https://<TOKEN>@github.com/<user_name>/<repo_name>.git |
| |
| |
| 打开 GitHub 在任意页面的右上角,单击个人头像,然后依次点击 Settings(设置)--> Developer settings(开发者设置) --> Personal access tokens(个人访问令牌)--> Generate new token(生成新令牌),选择要授予此令牌的作用域或权限。如果要使用令牌从命令行访问仓库,请勾选 repo(仓库)单击 Generate token(生成令牌) |
| |
| |
| git checkout master |

| |
| Nbextensions软件包是Jupyter非官方扩展包的集合,可以为Jupyter提供很多实用的功能。 |
| 这些扩展包大部分为Javascript编写,在运行Jupyter浏览器时被本地加载。 |
| (some) LaTeX environments for Jupyter : 支持更多的Latex元素 |
| 2to3 Converter : 将Python2代码转换为Python3代码的工具 |
| Addbefore : 在当前单元格前加入空单元格的功能 |
| Autopep8 : 代码格式化的工具(需要安装autopep8包) |
| Autosavetime : 可设置自动保存的时间间隔 |
| Autoscroll : 设置屏幕自动滚动阈值的工具 |
| Cell Filter : 依据标签过滤单元格的工具 |
| Code Font Size : 设置代码字体大小的工具 |
| Code preffify : 代码美化的工具(需要安装yapf包) |
| Codefolding : 增加折叠代码的功能(包括Python依据缩进折叠、其他代码依据方括号折叠、依据注释折叠) |
| Codefolding in Editor : |
| CodeMirror mode extensions : |
| Collapsible Headings : 存储markdown标题的折叠情况(在下一次打开的时候重新加载这点状态) |
| Comment/Uncomment Hotkey : |
| contrib_nbextensions_help_item : 添加帮助菜单 |
| datestamper : 将当前日期和时间粘贴到单元格中的工具 |
| Equation Auto Numbering : 公式自动编号工具 |
| ExecuteTime : 记录上一次运行代码单元的时间以及运行花费的时间 |
| Execution Dependencies : 记录单元格之间依赖关系的工具 |
| Exercise : 隐藏/显示单元格的功能(可以与Exercise2同时使用) |
| Exercise2 : 隐藏/显示单元格的功能(可以与Exercise同时使用) |
| Export Embedded HTML : 将notebook导出为HTML文件的工具 |
| Freeze : 提供单元格锁定、只读相关功能 |
| Gist-it : 一键发布Github的gist功能 |
| Help panel : 在工具栏中增加显示帮助说明的按钮 |
| Hide Header : 增加隐藏标题栏、菜单栏和工具栏的功能 |
| Hide input : 在工具栏中增加隐藏指定代码单元的功能 |
| Hide input all : 在工具栏中增加隐藏所有代码单元的功能 |
| Highlight selected word : 高亮显示被选中的对象以及所有代码单元中该对象的所有实例 |
| hightlighter : 在工具栏中增加荧光笔功能,可以高亮显示框选的内容 |
| Hinterland : 自动补全功能 |
| Initialization cells : 在工具栏中增加运行所有被框选为“初始化代码单元”的代码单元 |
| insort formatter : 排序代码单元中导入的包(需要安装isort包) |
| jupyter-js-widgets/extension : |
| Keyboard shortcut editor : 创建/修改/删除Jupyter的快捷键 |
| Launch QTConsole : 使用QTConsole内核 |
| Limit Output : 显示代码单元输出的文本或HTML的字符数 |
| Live Markdown Preview : |
| Load Tex macros : |
| Move selected cells: 在工具栏中增加上下移动单元格的功能 |
| Navigation-Hotkeys : 增加用于导航的快捷键 |
| Nbextensions dashboard tab : |
| Nbextensions edit menu item : |
| nb Translate : 在工具栏中增加语言翻译工具 |
| Notify : 增加在Jupyter内核空闲时的通知提示功能(适合运行很耗时的情况) |
| Printview : 在工具栏中增加将当前notebook输出为html或pdf的功能 |
| Python Markdown : 允许使用{{x}}的方法来直接输出结果 |
| Rubberband : 允许进行多个单元的选择 |
| Ruler : 增加标尺功能 |
| Ruler in Editor : |
| Runtools : 在工具栏中增加了更多运行各个单元的方法 |
| Scratchpad : 增加便笺式单元,可以针对当前内核执行代码,而无需修改notebook中的内容 |
| ScrollDown : 自动在选中单元格时向下滚动 |
| Select CodeMirror Keymap : 使用CodeMirror获取键盘映射,可以禁用非Jupyter的其他浏览器快捷键 |
| SKILL Syntax : CodeMirror的Skill模块 |
| Skip-Traceback : 跳过报错的路径追踪,只显示错误名称和类型的摘要 |
| Snippets : 在工具栏中增加添加指定代码单元的功能 |
| Snippets Menu : 在菜单栏中增加可自定义的菜单栏,用以插入代码片段 |
| spellchecker : 拼写检查,高亮显示拼写错误的单词 |
| Split Cells Notebook : 增加拆分单元格的命令 |
| Table of Contents(2) : 增加浮动目录功能 |
| table_beautifier : 美化输出的单元格 |
| Toggle all line numbers : 在工具栏中增加一个控制所有单元格行号是否显示的工具 |
| Tree Filter : 在Jupyter笔记本文件树页面中增加按文件名过滤的功能 |
| Variable Inspector : 在工具栏中增加变量检查的功能 |
| zenmode : 增加Zenmode功能扩展 |

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库