跳到主要内容

二十六、Docker 安装 Python

Python 是一门解释型、面向对象、动态数据类型的高级程序设计语言,入门简单易学习,Docker 安装 Python 有两种方法

我们以当前最新的版本 3.6.5 安装为例

1. docker pull python:3.6.5

这种方法非常适合只需要使用 Python 的开发者

1、 查找DockerHub上的python镜像;

    [root@pottercoding.cn ~]# docker search python
NAME DESCRIPTION OFFICIAL
python Python is an interpreted, interactive... [OK]
django Django is a free web application ... [OK]
pypy PyPy is a fast, compliant ... [OK]
...
有很多版本,我们选择官方最新的版本 python

2、 拉取官方的镜像,标签为3.6.5;

    [root@pottercoding.cn ~]# docker pull python:3.6.5
3.6.5: Pulling from library/python

3、 稍等片刻,下载完成后,就可以在本地镜像列表里看到 REPOSITORY 为 python,标签为 3.6.6 的镜像 [root@pottercoding.cn ~]# docker images python REPOSITORY TAG IMAGE ID CREATED SIZE python 3.6.5 29d2f3226daf 3 weeks ago 911.6 MB

一个 python 900m,我能说啥,这差不多是 10 倍的大小啊

4、 通过Dockerfile文件构建;

使用Dockerfile 文件构建的好处就是自己可以定制安装 Python 镜像