1,拉取最新ubuntu镜像
docker pull ubuntu
2,使用该镜像启动jupyter容器
docker run -p 8888:8888 -itd --name jupyter ubuntu /bin/bash
3,以进入后再退出容器终端不会导致容器的停止的方式进入容器
docker exec -it jupyter /bin/bash
4,修改成阿里源
tee /etc/apt/sources.list <<-'EOF'
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
5,检查可用的更新并更新
apt update -y
apt upgrade -y
6,安装一些必须软件(vim、curl、wget、python3、python3-pip)
apt install vim curl wget python3 python3-pip -y
7,更换pip国内源
mkdir ~/.pip
tee ~/.pip/pip.conf <<-'EOF'
[global]
trusted-host = mirrors.aliyun.com
index-url = https://mirrors.aliyun.com/pypi/simple
EOF
8,升级pip
pip3 install --upgrade pip
9,安装jupyterlab
pip install jupyterlab
10,安装nodejs
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt install nodejs -y
nodejs --version
11,生成jupyterlab的配置文件
jupyter lab --generate-config
12,生成密码
在终端输入ipython,在ipython中输入
from notebook.auth import passwd
passwd()
在其提示下输入密码后生成该密码的sha1码(如’sha1:bfacc3698c16:ffe503dxxxxx0e3483fffed5’),
复制该码备用
13,修改jupyterlab的配置文件
vim ~/.jupyter/jupyter_notebook_config.py
可修改以下配置等信息
c.NotebookApp.allow_root = True
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:bfacc3698c16:ffe503dxxxxx0e3483fffed5'# 此为上述密码的sha1码
c.NotebookApp.ip = '*'
c.NotebookApp.port = 8888
14,exit退出容器后可使用 docker commit 来提交容器副本生成我们的新镜像
docker commit -m="jupyterlab ubuntu" jupyter jupyterlab
15,可以使用 docker images 命令来查看新镜像