0
私は、Dockerfile
,app.py
およびrequirements.txt
を使って簡単なアプリケーションを構築しています。 Dockerfileがビルドされると、「No such file or directory」というエラーが表示されます。しかし、DockerfileのADDをCOPYに変更すると動作します。なぜこれが分かっていますか? https://docs.docker.com/get-started/part2/#define-a-container-with-a-dockerfileドッカー:ファイルを読み取っていない
App.py
from flask import Flask
from redis import Redis, RedisError
import os
import socket
# Connect to Redis
redis = Redis(host="redis", db=0, socket_connect_timeout=2, socket_timeout=2)
app = Flask(__name__)
@app.route("/")
def hello():
try:
visits = redis.incr("counter")
except RedisError:
visits = "<i>cannot connect to Redis, counter disabled</i>"
html = "<h3>Hello {name}!</h3>" \
"<b>Hostname:</b> {hostname}<br/>" \
"<b>Visits:</b> {visits}"
return html.format(name=os.getenv("NAME", "world"), hostname=socket.gethostname(), visits=visits)
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)
requirements.txt
Flask
Redis
:
私は、チュートリアルを使用しています最初の実行で210
Dockerfile
# Use an official Python runtime as a parent image
FROM python:2.7-slim
# Set the working directory to /app
WORKDIR /app
# Copy the current directory contents into the container at /app
ADD . /app
# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
# Make port 80 available to the world outside this container
EXPOSE 80
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
あなたが構築し、両方のログを表示することができますか? –
あなたのDockerfileをコピーしてビルドしようとしましたが、 'Dockerfile'と一緒に' requirements.txt'がすべてOKです。 –