In order to meet the need of serving static html files and dynamic python web-services having flask and nginx on one machine is more efficient than rendering static html file in python embeded code in Flask or any framework.
- docker build -t name/tag .
- docker run -d -p 80:80 name/tag
/app directory contains sample flask app routed to /service with just a welcome message return. You can fork this repo and more complex web-services that can return dynamic responses.
- Behind proxy DNS server to 8.8.8.8 in default vm of docker where docker host runs
- And set http_proxy and https_proxy
- While behind proxy remove those (commented ‘em)
- docker images | grep -vi image | awk '{print $3; cmd="docker rmi -f " $3; system(cmd)'}
- docker ps | grep -vi container | awk ‘{print $1; cmd=“docker kill “ $1; system(cmd)’}
- docker-machine ssh default
- sudo vi /var/lib/boot2docker/profile add following lines. export HTTP_PROXY=http://your.proxy.name:8080 export HTTPS_PROXY=http://your.proxy.name:8080
- docker-machine restart default
- Add following line in /etc/default/docker export HTTP_PROXY=http://your.proxy.name:8080 export HTTPS_PROXY=http://your.proxy.name:8080 DOCKER_OPTS="--dns-search --dns --dns --dns "
- You may also want to consider adding proxy settings in the docker image. ENV HTTP_PROXY 'http://your.proxy.name:port#' ENV HTTPS_PROXY 'https://your.proxy.name:port#'
Note: Remember on mac osx docker-machine has different architecutre since small kernel based VM is the running in virtual box along with docker deamon. Hence docker-machine and docker commands on your os-x are clients where as 'default' light weight VM is the server. And that server has to set the proxy in /var/lib/boot2docker/profile
http://flask.pocoo.org/docs/deploying/uwsgi/#configuring-nginx