## 实战:python环境
* 首先需要编写Dockerfile
```
FROM python:3.7 #使用python3.7官方image
LABEL maintainer = "bizzbee" #label:作者信息
RUN pip install flask #安装flask
COPY app.py /app/ #把本地的源码复制到容器根目录上的app目录
WORKDIR /app #进入/app目录
EXPOSE 5000 # 暴露5000端口
CMD ["python","app.py"] # 启动python项目入口
```
* 构建image
```
docker build -t bizzbee/python-flask-python3.7 .
```
* 启动容器,把本机5000端口映射到容器的5000端口
```
docker run -p 5000:5000 bizzbee/python-flask-python3.7
* 查看正在运行容器
```
```
[root@VM_0_11_centos ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
30bc495d1944 bizzbee/python-flask-python3.7 "python app.py" 3 hours ago Up 3 hours 0.0.0.0:5000->5000/tcp loving_euclid
```
* 测试
![](https://img.kancloud.cn/2c/ad/2cade7a99ae9bbc211f3804600150050_743x96.png)