Skip to content

Docker快速部署OCaml支持的Jupyter Notebook

获取Docker镜像

shell
docker pull akabe/ocaml-jupyter:latest

运行容器(单命令完成所有操作)

shell
docker run -it --rm \
  -p 8899:8888 \
  -v $(pwd)/ocaml-jupyter-docker:/workspace \
  --name ocaml_jupyter \
  akabe/ocaml-jupyter:latest \
  jupyter notebook \
  --ip=0.0.0.0 \
  --allow-root \
  --notebook-dir=/workspace \
  --no-browser \
  --NotebookApp.token='' \
  --NotebookApp.password=''

参数说明:

  1. -p 8899:8888:将宿主机8899端口映射到容器8888端口
  2. -v $(pwd)/notebooks:/workspace:挂载本地notebooks目录到容器
  3. --name ocaml_jupyter:为容器命名(便于管理)
  4. 直接启动Jupyter服务(无需二次手动启动)

访问Jupyter Notebook

在浏览器打开:

http://localhost:8899

无需token验证(因已禁用密码和token)


容器管理

a. 停止容器:

退出容器时,可以使用以下命令停止运行的容器:

shell
docker stop ocaml_jupyter

b. 重启容器

如果需要重新启动已存在的容器并回到交互环境:

shell
docker start -i ocaml_jupyter

如果只需启动 Jupyter Notebook:

shell
docker start ocaml_jupyter
docker exec -it my_jupyter_container jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root

c. 查看当前运行的容器

shell
docker ps

d. 进入容器

shell
docker exec -it ocaml_jupyter sh