828华为云征文 | 云服务器Flexus X实例,Docker集成搭建 Jupyter Notebook
Docker 部署 Jupyter Notebook 是一个方便且快速的方式,可以帮助你搭建一个用于数据分析、机器学习和科学计算的环境
华为云端口放行
- 服务器放行对应端口9955
Docker安装并配置镜像加速
1、购买华为云 Flexus X 实例
Flexus云服务器X实例-华为云 (huaweicloud.com)
2、docker安装
yum install -y docker-ce
3、验证 Docker 是否安装成功,启动docker服务并设置开机自启动,且查看docker状态
docker --version systemctl enable docker systemctl start docker systemctl status docker
4、docker-ce下载
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.huaweicloud.com/docker-ce/linux/centos/docker-ce.repo
5、路径/etc/yum.repos.d修改配置文件
[docker-ce-stable] name=Docker CE Stable - $basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/$basearch/stable enabled=1 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-stable-debuginfo] name=Docker CE Stable - Debuginfo $basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/debug-$basearch/stable enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-stable-source] name=Docker CE Stable - Sources baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/source/stable enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-test] name=Docker CE Test - $basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/$basearch/test enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-test-debuginfo] name=Docker CE Test - Debuginfo $basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/debug-$basearch/test enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-test-source] name=Docker CE Test - Sources baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/source/test enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-nightly] name=Docker CE Nightly - $basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/$basearch/nightly enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-nightly-debuginfo] name=Docker CE Nightly - Debuginfo $basearch baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/debug-$basearch/nightly enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg [docker-ce-nightly-source] name=Docker CE Nightly - Sources baseurl=https://repo.huaweicloud.com/docker-ce/linux/centos/9.9/source/nightly enabled=0 gpgcheck=1 gpgkey=https://repo.huaweicloud.com/docker-ce/linux/centos/gpg
6、清除和构建缓存
yum clean all yum makecache
7、docker配置镜像加速(在华为云镜像中心可获取自己的镜像加速配置)
8、创建镜像加速配置文件
vim /etc/docker/daemon.json
{ "registry-mirrors": [ "https://fd0cfec0ac0d446db7fd9d27e92d4a8e.mirror.swr.myhuaweicloud.com" ] }
9、重新加载配置文件,重新启动docker,查看是否配置成功
systemctl daemon-reload systemctl restart docker.service
10、docker info查看配置信息,是否配置成功镜像加速
docker info
搭建 Jupyter Notebook
1、拉取Jupyter Notebook镜像
docker pull jupyter/scipy-notebook
2、检查镜像是否拉取成功
docker images
3、运行容器
docker run --restart always -p 9955:8888 --name jupyter-notebook -d jupyter/scipy-notebook
--restart always
:确保容器在 Docker 重启或崩溃时自动重启
-p 8888:8888
:将主机的 9955端口映射到容器的 80端口,以便访问 Jupyter Notebook
--name jupyter-notebook
:为容器指定一个名称,方便后续管理
-d
:在后台运行容器
4、检查容器状态
docker ps
5、关闭防火墙
systemctl stop firewalld systemctl status firewalld
6、浏览器地址访问公网IP:9955
7、查看token
docker logs jupyter-notebook
http://d5101180164f:8888/lab?token=bb835ecff6908c88ccd61d9b6b3e6952f22670df4c9bd4dd
总结
华为云服务器Flexus X实例,Docker集成搭建 Jupyter Notebook交互式的计算环境,可以结合代码、文本、可视化和富媒体内容,广泛用于数据分析、机器学习和科研工作,有需要搭建的小伙伴可以购买华为云服务器搭建,目前服务器正在大促,优惠非常多!
华为云828 Flexus X实例