docker-compose启动有问题
来源:6-3 Docker Compose的安装和基本使用
苦瓜苦也
2020-04-14
然后docker-compose up报错
报错errno 2 找不到app.py这个文件。这三个文件都是老师的代码仓库拉下来的。
[root@host-192-168-167-170 flask-redis-compose]# cat app.py
from flask import Flask
from redis import Redis
import os
import socket
app = Flask(__name__)
redis = Redis(host=os.environ.get('REDIS_HOST', '127.0.0.1'), port=6379)
@app.route('/')
def hello():
redis.incr('hits')
return 'Hello Container World! I have been seen %s times and my hostname is %s.\n' % (redis.get('hits'),socket.gethostname())
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug=True)
[root@host-192-168-167-170 flask-redis-compose]# cat docker-compose.yml
version: "3"
services:
redis:
image: redis
web:
build:
context: .
dockerfile: Dockerfile
ports:
- 8080:5000
environment:
REDIS_HOST: redis
[root@host-192-168-167-170 flask-redis-compose]# cat Dockerfile
FROM python:2.7
LABEL maintaner="Peng Xiao xiaoquwl@gmail.com"
COPY . /app
WORKDIR /app
RUN pip install flask redis
EXPOSE 5000
CMD [ "python", "app.py" ]
写回答
1回答
-
麦兜搞IT
2020-04-17
你好,请您找到您的这个flask的docker image,然后运行
➜ flask-redis git:(master) ✗ docker run --rm -it flask-redis_web sh # # # cd /app # ls Dockerfile app.py docker-compose.yml #
比如我这里的image名字叫flask-redis-web 看看这个 /app下有没有这些文件
00
相似问题