自定义Docker镜像--Jupyterlab

概述

自定义Jupyterlab镜像,为deployment做准备

步骤

下载基础镜像:centos:7.9.2009

docker search centos:7.9.2009
docker pull centos:7.9.2009

启动容器 + 部署应用

# 启动容器
docker run -it --name test centos:7.9.2009 bash


# 在容器内部署应用服务
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

yum -y install vim git wget python3 python-pip epel-release gcc make gcc-c++ mysql redis

# 在容器内安装python module
pip3.6 install jupyterlab
pip3.6 install pymysql
pip3.6 install redis

# 重新构建python3的软连接
ls -al /usr/bin | grep python
ls -al /usr/bin | grep pip

mv /usr/bin/python /usr/bin/python.bakup
ln -s /usr/bin/python3.6 /usr/bin/python
ln -s /usr/bin/pip3.6 /usr/bin/pip

配置jupyterlab

执行命令:

jupyter lab --generate-config

自定义Docker镜像--Jupyterlab_第1张图片

修改配置文件:/root/.jupyter/jupyter_lab_config.py

# 查看正在运行容器
docker ps
# 将配置文件从容器中,copy到主机中
docker cp 66978dcc6378:/root/.jupyter/jupyter_lab_config.py ./

c.ServerApp.root_dir = '/home/jupyterlab'
c.ServerApp.allow_remote_access = True
c.ServerApp.ip = '*'
c.LabApp.open_browser = False
c.ServerApp.port = 8888
c.ServerApp.allow_root = True

配置启动文件:jupyter.service

# 启动文件转移出来
docker cp 66978dcc6378:/etc/systemd/system/jupyter.service ./

 查看内容:

[Unit]
Description=jupyter
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/jupyter-lab > /home/jupyter-lab.log
ExecReload=/bin/kill -s HUP $MAINPID
RestartSec=2s
Restart=on-failure

[Install]
WantedBy=multi-user.target

你可能感兴趣的:(kubernetes,cicd,+,jenkins,资源管理,kubernetes,docker)