交互式 .Net 容器版
背景介绍
在之前的文章 - 交互式 .Net 中已经介绍了什么是交互式 .Net,文中是通过 Visual Studio Code 插件的方式实现交互式 .Net 的。现在,我们将使用容器的方式实现交互式 .Net。
镜像构建
1. Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal ARG HTTP_PORT_RANGE=1100-1200 # Opt out of telemetry until after we install jupyter when building the image, this prevents caching of machine id
ENV DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT=true # Install all OS dependencies for notebook server that starts but lacks all
# features (e.g., download as all possible file formats) ENV DEBIAN_FRONTEND noninteractive
RUN sed -i 's|https\?://[^/]\+/|http://mirrors.aliyun.com/|' /etc/apt/sources.list
RUN apt-get update \
&& apt-get install -yq --no-install-recommends \
wget \
bzip2 \
ca-certificates \
sudo \
locales \
fonts-liberation \
run-one \
python3.8 \
python3-pip \
&& apt-get clean && rm -rf /var/lib/apt/lists/* RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
locale-gen RUN python3 -m pip install setuptools
RUN python3 -m pip install jupyter
RUN python3 -m pip install jupyterlab # Add package sources
RUN dotnet nuget add source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" -n "dotnet-tools"
RUN dotnet nuget add source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" -n "dotnet6"
RUN dotnet nuget add source "https://pkgs.dev.azure.com/dnceng/public/_packaging/MachineLearning/nuget/v3/index.json" -n "MachineLearning" # Install lastest build from master branch of Microsoft.DotNet.Interactive
RUN dotnet tool install --tool-path /usr/share/dotnet-interactive Microsoft.dotnet-interactive --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"
RUN ln -s /usr/share/dotnet-interactive/dotnet-interactive /usr/bin/dotnet-interactive
RUN dotnet interactive jupyter install --http-port-range ${HTTP_PORT_RANGE} # Enable telemetry once we install jupyter for the image
ENV DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT=false EXPOSE 8888
EXPOSE ${HTTP_PORT_RANGE} RUN groupadd -g 1337 jupyter
#RUN groupdel jupyter RUN mkdir notebooks WORKDIR notebooks ENV TOKEN '' ENTRYPOINT jupyter lab --ip=0.0.0.0 --allow-root --notebook-dir=/notebooks/ --ServerApp.token=${TOKEN}
2. 构建镜像
docker build -t dotnet-interactive:1.0.0 .

启动容器
执行以下指令启动容器:
docker run --name dotnet-interactive -d -e TOKEN=123456 -v /root/notebooks:/notebooks -p 80:8888 dotnet-interactive:1.0.0

指令解析:
| docker run | 启动 docker 容器 |
| -- name dotnet-interactive | 设置容器名称为 nginx |
| -d | 后台运行 |
| -e TOKEN=123456 | 设置访问密码为 123456,可根据需要进行调整 |
| -v /root/notebooks:/notebooks | 把容器目录挂载到宿主机 |
| -p 80:8888 | 把宿主机的 80 端口映射到容器的 8888 端口 |
| dotnet-interactive:1.0.0 | 使用镜像 |
使用介绍
1. 打开网页并登录

2. 新建 Notebook

3. 解析 Markdown
输入一段 markdown 内容,并选择 Markdown,使用热键 Alt+Enter 查看结果

4. 执行 C# 代码
输入一段 C# 代码,并选择 Code,使用热键 Alt+Enter 查看结果

5. 获取操作系统信息

6. 获取 .Net 版本

7. 获取 ipynb 文件
可以在宿主机的 /root/notebooks 路径下获取刚才操作的 ipynb 文件:

参考总结
以上就是本文希望分享的内容,其中 interactive 的 Github 地址为:https://github.com/dotnet/interactive
如果大家有什么问题,欢迎在文章或者在公众号 - 跬步之巅留言交流。
交互式 .Net 容器版的更多相关文章
- 容器版Jenkins连接Kubernetes---------非容器版jenkins是无法安装kubenetes插件的,所以无法连接k8s
容器版Jenkins连接Kubernetes 特别注意:必须用谷歌浏览器,而且非容器版jenkins是无法安装kubernetes插件的,所以无法连接k8s 一.环境说明 OS系统版本:Ubuntu ...
- 容器版jenkins安装并且实现使用宿主机docker命令,采用的是docker outside deocker,带jdk、添加maven、git
docker版jekins使用宿主机docker命令 docker版jekins安装,实现CI/CD,也就是实现在容器里面使用宿主机docker命令,这样方式为:docker outside deoc ...
- 容器版Jenkins官方镜像 本身自带了 Java
docker版Jenkins官方镜像 本身自带了 Java
- jenkins--master/slave模式---master是容器版---slave是非容器版
实验架构: 192.168.0.96 gitlab 192.168.0.97 jenkins.tomcat 192.168.0.98 harbor.docker集群.git.jdk.maven 1.先 ...
- 容器版单个jenkins实现CI/CD----带solo博客开源项目
实验架构: 192.168.0.96 gitlab 192.168.0.97 jenkins.docker-1.7 192.168.0.98 harbor.docker-1.7集群 jenkins安装 ...
- Docker容器版Jumpserver堡垒机搭建部署方法附Redis
1.简介 Jumpserver是全球首款完全开源的堡垒机,多云环境下更好用的堡垒机,使用GNU GPL v2.0开源协议,是符合 4A 的专业运维安全审计系统,使用Python / Django 进行 ...
- 伤透了心的pytorch的cuda容器版
公司GPU的机器版本本比较低,找了好多不同的镜像都不行, 自己从anaconda开始制作也没有搞定(因为公司机器不可以直接上网), 哎,官网只有使用最新的NVIDIA驱动,安装起来才顺利. 最后,找到 ...
- 容器版jenkins使用宿主机的docker命令
参照里面的第一步里面的dockerfile: https://www.cnblogs.com/effortsing/p/10486960.html
- 容器版jenkins使用宿主机的kubectl命令
参照里面的第4步: https://www.cnblogs.com/effortsing/p/10486960.html
随机推荐
- MySQL碎片整理小节--实例演示
MYSQL之磁盘碎片整理 清澈,细流涓涓的爱 数据库引擎以InnoDB为主 1.磁盘碎片是什么 InnoDB表的数据存储在页中,每个页可以存放多条记录,这些记录以树形结构组织,这棵树称为B+树. ...
- 18个基于 HTML5 Canvas 开发的图表库
如今,HTML5 可谓如众星捧月一般,受到许多业内巨头的青睐.很多Web开发者也尝试着用 HTML 5 来制作各种各样的富 Web 应用.HTML 5 规范引进了很多新特性,其中之一就是 Canvas ...
- 解决canvas画图模糊的问题
canvas 画图经常发现他是模糊的.解决这个问题主要从两个方面下手. 改变canvas渲染的像素情况:画1像素的线条看起来模糊不清,好像更宽的样子. 解决方案 var ctx = canvas.ge ...
- Vue-cli的打包初体验
前言:我司是一个教育公司,最近要做一个入学诊断的项目,领导让我开始搭建一套基于vue的H5的开发环境.在网上搜集很多的适配方案,最终还是选定flexible方案.选择它的原因很简单: 它的github ...
- 【uniapp 开发】文字缩略css
文字超出两行后显示省略号 display: -webkit-box; overflow: hidden; text-overflow: ellipsis; word-wrap: break-word; ...
- java中downcast向下转型到底有什么用
What is the point of downcast? 当一个方法只有子类才有,马克-to-win:不是说基类和子类都有,开始时又是基类指针指向派生类,这时就需要downcast, see th ...
- CentOS的安装以及IP地址(动态/静态)的配置
啊!复试压力好大,跟好多学长聊完以后觉得自己更该好好努力了,一边好好准备复试科目,一边把之前忘掉的捡起来吧,加油! 1.安装的具体过程请参照这位博主写的,我觉得写的很详细,https://blog.c ...
- mysql在cmd中查询到的汉字乱码问题解决 方法一
只要执行如上两个 set character_set_connection = gbk; set character_set_results= gbk; 将编码格式转换成gbk即可
- response.setHeader("Cache-Control","no-cache");的作用
1. response.setHeader("Cache-Control","no-cache"); This is used to prevent the ...
- windows下的volatility取证分析与讲解
volatility(win64) 1.下载 volatility 下载地址:(我下载的版本2.6,并把名字稍微改了一下) Release Downloads | Volatility Foundat ...