私はボトルフレームワークでアプリケーションを実行するためにコンテナを設定しようとしています。私がそれについて見つけることができるすべてを読んでください、しかし私はそれをすることはできません。ここに私がやったことだ:bottle.pyアプリケーションをビルドして実行できません
Dockerfile:
# Use an official Python runtime as a parent image
FROM python:2.7
# 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 8080
# Define environment variable
ENV NAME World
# Run app.py when the container launches
CMD ["python", "app.py"]
app.py:
import os
from bottle import route, run, template
@route('/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8080)
requirements.txt
bottle
docker build -t testapp
コマンドを実行すると、コンテナが作成されます。
は次にコマンドdocker run -p 8080:8080 testapp
を実行して、私はこの端子出力を得る:
Bottle v0.12.13 server starting up (using WSGIRefServer())... Listening on http://localhost:8080/ Hit Ctrl-C to quit.
をしかし、私はlocalhost:8080/testing
に行くとき、私はlocalhost refused connection
を取得します。
誰でも正しい方向に向けることができますか?
これはRobertoさんに感謝しました! –