date: 2025-04-13
title: Mac2Docker
status: DONE
author:
  - AllenYGY
tags:
  - NOTE
  - Docker
publish: trueMac2Docker
docker pull akabe/ocaml-jupyter:latest
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=''
-p 8899:8888:将宿主机8899端口映射到容器8888端口-v $(pwd)/notebooks:/workspace:挂载本地notebooks目录到容器--name ocaml_jupyter:为容器命名(便于管理)在浏览器打开:
http://localhost:8899
无需token验证(因已禁用密码和token)
退出容器时,可以使用以下命令停止运行的容器:
docker stop ocaml_jupyter	
如果需要重新启动已存在的容器并回到交互环境:
docker start -i ocaml_jupyter	
如果只需启动 Jupyter Notebook:
docker start ocaml_jupyter
docker exec -it my_jupyter_container jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root
docker ps
docker exec -it ocaml_jupyter sh