Reputation: 1811
I have a small web application the runs on a flask server, which can normally be run on local host, by running app.py. I would like to run it in a docker container, so I cannot use localhost. An alternative would be using 0.0.0.0
, which works fine normally, however this does not work when I'm on my work proxy.
How could I get past this issue?
app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def main():
return render_template('index.html')
if __name__ == "__main__":
app.run(host='0.0.0.0')
Dockerfile
FROM python:2.7.13
ADD . /code
WORKDIR /code
RUN pip install Flask --proxy=[proxy]
CMD ["python", "app.py"]
Upvotes: 0
Views: 790
Reputation: 146630
You don't need to use a proxy inside the container. Whatever is needed will be external to the container/image. Whether your run in corporate environment or home.
When you use docker run -p 5000:5000 <yourimage>
. It maps the port 5000 from inside the container to all interfaces on your machine.
Now if you machine is reachable from other machines in network, then they need to use http://<yourreachablemachineip>:5000
. Also if for some reason a proxy is needed then you will need to apply that proxy to docker daemon and not to inside the docker container. See below thread for more details on the same
lookup registry-1.docker.io: no such host
Upvotes: 1