mac docker安装jupyter notebook镜像

一、Mac上安装docker服务-安装desktop docker

1.从docker官网下载docker.dmg并安装

下载网址:https://hub.docker.com/editions/community/docker-ce-desktop-mac/

安装教程:https://docs.docker.com/docker-for-mac/install/

2.注册账户-在dockerhub网址上

https://hub.docker.com/

3.镜像加速

鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,我们可以需要配置加速器来解决。

在任务栏点击 Docker for mac 应用图标 -> Perferences... -> Settings Docker Engine.

在json字符串中添加一项:

"registry-mirrors": [
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com/"
]

https://registry.docker-cn.com是docker官方给的中国镜像库;

http://hub-mirror.c.163.com/是网易的镜像库。

参考:https://www.runoob.com/docker/docker-mirror-acceleration.html

检查加速器是否生效

$docker info

Registry Mirrors:

  https://registry.docker-cn.com/

  http://hub-mirror.c.163.com/

二、docker上安装jupyter notebook镜像

1.拉取jupyter notebook镜像

先在官网上找镜像

https://hub.docker.com/

https://hub.docker.com/search?q=jupyter-notebook&type=image

选择一个Downloads和Star最多的镜像:maxmtmn/jupyter-notebook-custom

 https://hub.docker.com/r/maxmtmn/jupyter-notebook-custom

在网页右边可以看到pull命令的写法,在终端执行,下载镜像

docker pull maxmtmn/jupyter-notebook-custom

查看本地镜像

$docker images

REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE

hello-world                       latest              fce289e99eb9        14 months ago       1.84kB

maxmtmn/jupyter-notebook-custom   latest              12e066915ae7        2 years ago         3.73GB

2.构建容器

$docker run -p 7777:8888 maxmtmn/jupyter-notebook-custom

docker run 是产生容器的命令,而-p 7777:8888的意思是服务器本身的7777端口会映射到container里面的8888端口,前面的7777可以更改为别的数字,只要别和服务器自身已经使用的端口产生冲突就好,后边的8888最好别更改,因为8888是jupyter notebook的默认端口,若是这里改动了8888,就要相对应更改。

Execute the command: jupyter notebook

[I 08:08:24.857 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret

[W 08:08:24.949 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.

[I 08:08:25.017 NotebookApp] JupyterLab alpha preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab

JupyterLab v0.27.0

Known labextensions:

[I 08:08:25.023 NotebookApp] Running the core application with no additional extensions or settings

[I 08:08:25.026 NotebookApp] Serving notebooks from local directory: /home/jovyan

[I 08:08:25.026 NotebookApp] 0 active kernels 

[I 08:08:25.027 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=1163b30f0c9bf3c6606611f64bb299c106bdaa37fb8fb7a7

[I 08:08:25.027 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

[C 08:08:25.029 NotebookApp] 

    

    Copy/paste this URL into your browser when you connect for the first time,

    to login with a token:

        http://localhost:8888/?token=1163b30f0c9bf3c6606611f64bb299c106bdaa37fb8fb7a7

参考:https://blog.csdn.net/weixin_40008349/article/details/81135847

 3.本地浏览器登陆docker中jupyter notebook
本地浏览器输入:http://localhost:7777/tree
再输入token:1163b30f0c9bf3c6606611f64bb299c106bdaa37fb8fb7a7即可。
 

4.以后再次登陆

docker命令

查看本地docker镜像

$docker images

REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE

hello-world                       latest              fce289e99eb9        14 months ago       1.84kB

maxmtmn/jupyter-notebook-custom   latest              12e066915ae7        2 years ago         3.73GB

查看本地docker容器

$docker ps -a

CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS                    PORTS               NAMES

1d109e5cb00c        maxmtmn/jupyter-notebook-custom   "tini -- start-noteb…"   24 hours ago        Exited (0) 21 hours ago                       jolly_wu

445bd4a5b8df        hello-world                       "/hello"                 25 hours ago        Exited (0) 25 hours ago                       wonderful_lederberg

425da93215d2        hello-world                       "/hello"                 27 hours ago        Exited (0) 26 hours ago                       hardcore_taussig

再次登陆docker中的jupyter notebook

$docker start 1d109e5cb00c

1d109e5cb00c

本地浏览器输入:http://localhost:7777/tree即可。

5.停止容器

$docker stop 容器ID

1d109e5cb00c

http://localhost:7777/tree

原文地址:https://www.cnblogs.com/xl717/p/12427086.html