1、使用官方一键安装脚本
curl -sSL https://get.docker.com/ | sh
若报错
package docker-ce-3:19.03.2-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
安装新版的containerd.io软件包
wget https://download.docker.com/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
yum -y install containerd.io-1.2.6-3.3.el7.x86_64.rpm
再次安装脚本
curl -sSL https://get.docker.com/ | sh
2、启动docker
systemctl start docker
若报错
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock
执行
sudo service docker start
再执行
docker run hello-world
3、查找python镜像
docker search python
这里选择了centos/python-36-centos7
docker pull centos/python-36-centos7
查找python镜像id
docker search python
启动镜像
docker run -it -v /home/data:/dpjob -p 8888:8888 d67307610df0 /bin/bash
说明
- List -v:/dpjob是我们在容器下操作的目录,与之对应宿主机的挂在目录为/home/data,也就是说我们在容器/dpjob下的操作就相当于在宿主机下的/home/data下操作。
- -p:将机器的 8888 端口(前者)映射到容器暴露的 8888 端口(后者)
- d67307610df0是python的id
安装jupyter
pip install jupyter
生成jupyter配置文件
jupyter notebook --generate-config
使用ipython生成密码
In [1]: from notebook.auth import passwd
In [2]: passwd()
Out[2]: 'sha1:******'
去配置文件.jupyter/jupyter_notebook_config.py中修改以下参数
在这里c.NotebookApp.ip='*' #绑定所有地址
c.NotebookApp.password = u' 刚才生成的密码'
c.NotebookApp.open_browser = False #启动后是否在浏览器中自动打开
c.NotebookApp.port =8888 #指定一个访问端口,默认8888,注意和映射的docker端口对应
启动
jupyter notebook --allow-root
版权声明:本文为u011463878原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。