J'ai essayé de configurer un conteneur pour exécuter une application avec le cadre de la bouteille. Lisez tout ce que je pourrais trouver à ce sujet, mais même si je ne peux pas le faire. Voici ce que je l'ai fait:Impossible de créer et d'exécuter une application 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
En exécutant la commande docker build -t testapp
, je crée le conteneur.
Puis en exécutant la commande docker run -p 8080:8080 testapp
je reçois cette sortie de terminal:
Bottle v0.12.13 server starting up (using WSGIRefServer())... Listening on http://localhost:8080/ Hit Ctrl-C to quit.
Mais quand je vais à localhost:8080/testing
je reçois localhost refused connection
.
Quelqu'un peut-il me diriger dans la bonne direction?
Cela a fonctionné grâce à Roberto! –