dockerfile部署flask接口服务

dockerfile文件如下:

FROM python:3.7.13-slim

COPY judge /home/judge

RUN cd /home/judge && \
	pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple && \
	pip install -r requirements.txt

EXPOSE 6666

CMD cd /home/judge && python /home/judge/app.py

注意事项:

先进入到app.py相应的文件路径下,再执行python app.py

CMD cd /home/judge && python /home/judge/app.py

docker build -t ai/judge:0.0.1 . #在dockerfile文件同路径下,执行
docker run  -p 16666:6666 -itd --name ai-judge ai/judge:0.0.1 #接口映射:容器内服务端口号6666映射到主机16666端口
docker start  ai-judge #启动容器
docker logs -f --tail 500  ai-judge #仅列出容器内最新的500条日志
docker exec -it ai-judge /bin/sh
docker rm -f   ai-judge

你可能感兴趣的:(Docker,flask,python,docker)