docker-compose篇---创建jupyter并可用sudo的创建方式
python
version: '3'
services:
jupyter:
image: jupyter/scipy-notebook:latest
ports:
- "8888:8888"
- "9000:8000"
- "2223:22"
volumes:
- ./notebooks:/home/jovyan/work
environment:
- NB_UID=0 # 设置为 0,表示 root 用户的 UID
- NB_GID=0 # 设置为 0,表示 root 用户的 GID
- CHOWN_HOME=no # 不更改 home 目录的所有权
- CHOWN_HOME_OPTS='-R'
- JUPYTER_ENABLE_LAB=yes
- JUPYTER_TOKEN=abc@1234
- GRANT_SUDO=yes # 授权 sudo 权限
command: bash -c "echo 'root:123456' | chpasswd && start-notebook.sh --NotebookApp.custom_display_url=http://localhost:8888"
container_name: jupyter
restart: always
network_mode: "host"