首页 > 其他 > 详细

服务器Docker-Compose 安装 Anaconda

时间:2021-05-14 21:16:19      阅读:40      评论:0      收藏:0      [点我收藏+]

前置:Docker、Docker-Compose的安装以及相关使用

一、docker-compose.yml

version: ‘3.1‘
services:
  anaconda:
    restart: always
    image: continuumio/anaconda3
    container_name: anaconda
    ports:
      - 8888:8888
    environment:
      TZ: Asia/Shanghai
    command: /bin/bash -c "mkdir -p /mnt/app &&./mnt/app/entrypoint.sh"
    volumes:
      - ./app:/mnt/app

二、文件准备

1. 在yml文件同级目录下创建目录app

mkdir ./app

2. 在app目录下创建两个文件

entrypoint.sh

#!/bin/bash
echo y|conda install -c conda-forge jupyterlab
echo y|jupyter notebook --generate-config
sha1=`python3 /mnt/app/setPwd.py`
echo $sha1
echo "c.NotebookApp.ip=‘*‘                          #绑定所有地址,即所有IP 地址都可以访问" >> /root/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.password = u‘$sha1‘" >> /root/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.open_browser = False            #启动后是否在浏览器中自动打开" >> /root/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.port =8888                      #指定一个访问端口默认8888" >> /root/.jupyter/jupyter_notebook_config.py
echo "c.NotebookApp.allow_remote = True     #将远程访问设置成True" >> /root/.jupyter/jupyter_notebook_config.py
pip --default-timeout=100 install -U jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip --default-timeout=100 install -U jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
jupyter notebook --allow-root

setPwd.py

from notebook.auth import passwd
# 密码:12345
print(passwd("12345","sha1"))

三、启动docker

docker-compose up -d

四、设置代码提示

点击Nbextensions选项卡勾选Hinterland,使用Jupyter敲几行代码试试,终于摆脱每次按tab键的烦恼了

技术分享图片

服务器Docker-Compose 安装 Anaconda

原文:https://www.cnblogs.com/zzxaaas/p/14769516.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!