之前用docker 运行python web服务现在用docker-compose来启动
python web还是用之前的最简单的那个ops
相关docker-compose.yml, Dockerfile, ops工程, 及相关包打包上传,点击下载
- 编写docker-compose
docker-compose.yml
version: '3'
services:
web:
build: .
ports:
- 9999:8888
volumes:
- /root/docker/dockerfile:/code
privileged: true
restart: always
Dockerfile
沿用之前的
FROM python:2
ADD Django-1.8.3.tar.gz /usr/local/src
WORKDIR /usr/local/src/Django-1.8.3
RUN python setup.py install
ADD ops.tar.gz /code
WORKDIR /code/ops
ENV PATH /usr/bin/python:$PATH
EXPOSE 8888
CMD ["/bin/bash", "run.sh"]
Dockerfile会调用run.sh
脚本,该脚本启动python服务的8888端口,通过docker-compose将8888端口从docker容器中映射到本机的9999端口
3. docker-compose up
启动