我想使用docker-stack安装一个python2.x的jupyter容器。
GitHub为jupyter/docker-stack提供的文档显示:
Python2.x于2017年8月10日从所有图片中删除,从标签cc9feab481f7开始。如果希望继续使用Python2.x,请将pin标记为82b978b3ceeb。
请参阅:https://github.com/jupyter/docker-stacks
我假设您按如下方式运行,例如,安装最小笔记本:
docker run -it --rm -p 8888:8888 jupyter/minimal-notebook:82b978b3ceeb但是在运行之后,我发现python 3.x已经安装:
sys.version_info(major=3,minor=6,micro=2,releaselevel='final',serial=0)
下面是“docker”命令的输出:
$ docker run -it --rm -p 8888:8888 jupyter/minimal-notebook:82b978b3ceeb
/usr/local/bin/start.sh: line 48: [: missing `]'
/usr/local/bin/start.sh: line 48: : command not found
Execute the command
[I 20:55:49.950 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[W 20:55:49.979 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 20:55:50.010 NotebookApp] JupyterLab alpha preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
JupyterLab v0.24.1
Known labextensions:
[I 20:55:50.013 NotebookApp] Running the core application with no additional extensions or settings
[I 20:55:50.016 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 20:55:50.016 NotebookApp] 0 active kernels
[I 20:55:50.017 NotebookApp] The Jupyter Notebook is running at: http://[all ip addresses on your system]:8888/?token=f09a12bf53902cb20aca2f1924011e1e80d51243cc10a390
[I 20:55:50.017 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:55:50.017 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=f09a12bf53902cb20aca2f1924011e1e80d51243cc10a390发布于 2018-02-02 22:13:24
有一个在FROM中创建Python2Conda环境的方法-- GitHub wiki上的核心映像之一:https://github.com/jupyter/docker-stacks/wiki/Docker-recipes#add-a-python-2x-environment
发布于 2018-06-21 13:23:18
我注意到在以前的职位中建议的以前的职位已经不在了,所以我在这里做了一些修改。
您可以创建以下Dockerfile:
# From https://github.com/jupyter/docker-stacks/wiki/Docker-recipes#add-a-python-2x-environment
# Choose your desired base image: you could use another from https://github.com/busbud/jupyter-docker-stacks
FROM jupyter/all-spark-notebook:latest
# Create a Python 2.x environment using conda including at least the ipython kernel
# and the kernda utility. Add any additional packages you want available for use
# in a Python 2 notebook to the first line here (e.g., pandas, matplotlib, etc.)
RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda && \
conda clean -tipsy
USER root
# Bundle requirements
# You can change the libraries in the file
# requirements.txt
ADD requirements.txt /requirements.txt
# Create a global kernelspec in the image and modify it so that it properly activates
# the python2 conda environment.
RUN $CONDA_DIR/envs/python2/bin/python -m ipykernel install && \
$CONDA_DIR/envs/python2/bin/kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json && \
pip install -r /requirements.txt && \
rm /requirements.txt && \
USER $NB_USER或者如果您没有要求
# From https://github.com/jupyter/docker-stacks/wiki/Docker-recipes#add-a-python-2x-environment
# Choose your desired base image: you could use another from https://github.com/busbud/jupyter-docker-stacks
FROM jupyter/all-spark-notebook:latest
# Create a Python 2.x environment using conda including at least the ipython kernel
# and the kernda utility. Add any additional packages you want available for use
# in a Python 2 notebook to the first line here (e.g., pandas, matplotlib, etc.)
RUN conda create --quiet --yes -p $CONDA_DIR/envs/python2 python=2.7 ipython ipykernel kernda && \
conda clean -tipsy
USER root
# Create a global kernelspec in the image and modify it so that it properly activates
# the python2 conda environment.
RUN $CONDA_DIR/envs/python2/bin/python -m ipykernel install && \
$CONDA_DIR/envs/python2/bin/kernda -o -y /usr/local/share/jupyter/kernels/python2/kernel.json &
USER $NB_USER然后转到文件夹:创建映像:docker build -t wm/ubuntupython2jupyterpyspark:v1.0 . wm/ubuntupython2jupyterpysight:v1.0只是一个例子,您可以再举一个例子
运行容器
docker run -p 8888:8888 wm/ubuntupython2jupyterpyspark:v1.0
https://stackoverflow.com/questions/48590900
复制相似问题