我一直在試圖設置一個容器來運行瓶框架的應用程序。閱讀我能找到的所有信息,但即使如此,我也無法做到。下面是我所做的:無法管理建立和運行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
。
任何人都可以指向正確的方向嗎?
這工作感謝羅伯託! –