docker 安裝jupyterhub支持R語言

docker安裝

systemctl stop firewalld.service

systemctl disable firewalld.service

yum install -y yum-utils device-mapper-persistent-data lvm2

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

yum makecache fast

yum -y install docker-ce

systemctl start docker

下載jupyterhub鏡像

docker pull jupyterhub/jupyterhub

啓動docker

docker run -p 8000:8000 -d --name jupyterhub  -v /data/jupyterhub/jupyterhub:/srv/jupyterhub -v /data/jupyterhub/home:/home --restart=always jupyterhub/jupyterhub jupyterhub

訪問jupyterhub

因爲Jupyterhub是使用系統的賬號和密碼,所以需要登陸到docker容器裏去創建系統賬號和密碼

登陸docker 容器

docker exec -it jupyterhub bash

useradd jupyterhub

passwd jupyterhub

輸入兩次密碼


更新pip

pip install --upgrade pip

更新jupyterhub

pip install --upgrade jupyterhub

默認docker沒有安裝notebook,不執行這條命令,無法使用jupyterhub

pip install notebook --upgrade

打開瀏覽器,http://IP:8000,會出現500的錯誤,因爲jupyterhub使用的的home目錄沒有權限,需要去添加權限,home目錄是保存jupyterhub notebook文件的路徑

chmod -R 777  /data/home/

添加好權限後就可以正常訪問,輸入剛纔創建的系統賬號和密碼

image.png

如果需要支持R語言的話,需要安裝R內核

conda install -c r r-essentials

R內核安裝好後,還是會出現各種錯誤

再執行如下命令

apt-get install r-base r-base-dev

測試R語言是否可以正常使用


登陸http://IP:8000

image.png

查看已安裝的R語言包

installed.packages()

image.png

可以打開docker日誌查看並排錯

docker logs -f jupyterhub

如果想省事,怕麻煩,直接下載我打好的jupyterhub_r的docker鏡像

docker pull 564239555/jupyterhub_r

直接啓動就好

docker run -p 8000:8000 -d --name jupyterhub  -v /data/jupyterhub/jupyterhub:/srv/jupyterhub -v /data/jupyterhub/home:/home --restart=always 564239555/jupyterhub_r jupyterhub

啓動好後給home目錄添加權限,進入docker容器創建賬號和密碼,就可以正常使用了






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章