簡體   English   中英

在 Docker 上的 Anaconda 下運行 jupyter notebook

[英]Running jupyter notebook under Anaconda on Docker

我正在按照此處給出的說明通過 Docker 在 Anaconda 下運行 Jupyter 筆記本。

在這段代碼中:

docker run -i -t -p 8888:8888 continuumio/miniconda /bin/bash
-c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir
/opt/notebooks && /opt/conda/bin/jupyter notebook
--notebook-dir=/opt/notebooks --ip='*' --port=8888
--no-browser"

我在運行這件作品時出現故障:

/opt/conda/bin/jupyter notebook
    --notebook-dir=/opt/notebooks --ip='*' --port=8888
    --no-browser"

這是出現的錯誤:

[I 19:20:47.620 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'allow_remote_access'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 864, in _default_allow_remote
    addr = ipaddress.ip_address(self.ip)
  File "/opt/conda/lib/python3.7/ipaddress.py", line 54, in ip_address
    address)
ValueError: '' does not appear to be an IPv4 or IPv6 address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "</opt/conda/lib/python3.7/site-packages/decorator.py:decorator-gen-7>", line 2, in initialize
  File "/opt/conda/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 1628, in initialize
    self.init_webapp()
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 1378, in init_webapp
    self.jinja_environment_options,
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 159, in __init__
    default_url, settings_overrides, jinja_env_options)
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 252, in init_settings
    allow_remote_access=jupyter_app.allow_remote_access,
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "/opt/conda/lib/python3.7/site-packages/traitlets/traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "/opt/conda/lib/python3.7/site-packages/notebook/notebookapp.py", line 867, in _default_allow_remote
    for info in socket.getaddrinfo(self.ip, self.port, 0, socket.SOCK_STREAM):
  File "/opt/conda/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

我用幾個不同的圖像嘗試過這個,但總是卡在同一個地方。

有人有線索嗎?

您希望筆記本綁定到通配符地址, 0.0.0.0將綁定到網絡內的所有主機,這就是您在這里想要的(docker 容器就像自包含網絡)。

我不確定*會導致什么結果,它似乎匹配一個空地址''

一步步:

  1. docker run -i -t -p 8888:8888 store/continuumio/anaconda:4.0.0

  2. conda install jupyter -y — quiet

  3. mkdir /opt/notebooks

  4. jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser

下次要開始時:

  1. docker start "container_id"
  2. docker exec "container_id" jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browse

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM