 
                https://www.docker.com/whatisdocker/
 
                 
                docker run automatically does (docker pull) - downloading the image/etc/issue shows Debian 7, but uname -r shows Arch Linux (host-OS)docker run -ti --rm debian:wheezy /bin/bashdocker run creates a new container from an image-t creates a pseudo terminal (for output)-i gives access to stdin--rm ensures that the container is discarded after the main process exits
                            docker restartdebian:wheezy is the name of the image, here with tag wheezy. Without a tag :latest would be used./bin/bash is the command that should be executed by the container. Images usually have a default command that can be overwritten at run-timeFROM debian:wheezy)RUN apt-get update are executed in temporary containers, result in layers → layers can be re-used by several images, enable build-cachingEXPOSE 80 in a Dockerfile opens port 80, for now only for other containersdocker run -p 80:80 forwards port 80 to the host
                            docker run -p [interface:]80:80 binds the port to a certain interface (e.g. localhost)docker run -p 8000:80 forwards container port 80 to 8000 on the hostEXPOSEd, if docker run is called with the --link parameter-p 6379:6379 the host cannot access the redis instance in the containerEXPOSEd) with --linkdocker run -v, or with VOLUME in the Dockerfile--volumes-fromdocker run -v /local/path:/path/in/container files and folders of the host can be mounted into the containerpython3 -m http.server starts a development server on port 8000-v $(pwd):/opt mounts the current directory into the path /opt in the container 
                    from flask import Flask, render_template, redirect, url_for, json, request
from flask.ext.sse import sse, send_event
app = Flask(__name__)
app.config['SSE_REDIS_HOST'] = 'redis' #default=='localhost'; 'redis' => --link
app.register_blueprint(sse, url_prefix='/events')
@app.route('/new')
def new():
    return render_template('message.html')
@app.route('/send', methods=['POST'])
def send():
    data = {"message": request.form.get('message', 'Hello, world!')}
    send_event("testevent", json.dumps(data), channel='test')
    return redirect(url_for('new'))
@app.route('/')
def index():
    return render_template('index.html')# python2 due to gevent; wheezy based image, otherwise problems with gevent
# https://github.com/gevent/gevent/issues/513
FROM python:2.7.9-wheezy
MAINTAINER Jesaja Everling <jesaja@everling.email>
ENV MODIFIED_AT 201512061738
RUN pip install gunicorn gevent \
"git+https://github.com/DazWorrall/flask-sse.git"
ADD flask-sse/example /opt/flask-sse
WORKDIR /opt/flask-sse
CMD /opt/flask-sse/run.sh
/opt/flask-sse
                            docker build -t flask-sse_gunicorn .flask-sse_gunicorn, container can the be started with docker run flask-sse_gunicornFROM nginx:1.7.9
ADD default.conf /etc/nginx/conf.d/default.conf
upstream gunicorn {
    server flask-sse_gunicorn:5000 fail_timeout=0;
}
server {
    listen 80;
    location / {
      proxy_redirect off;
      proxy_set_header Host $http_host;
      # http://stackoverflow.com/a/13673298/204706
      proxy_set_header Connection '';
      proxy_http_version 1.1;
      chunked_transfer_encoding off;
      proxy_buffering off;
      proxy_cache off;
      proxy_pass http://gunicorn;
    }
}
default.conf is replaced
                        docker run -v$(pwd)/default.conf:/etc/nginx/conf.d/default.conf nginxredis containerdocker run -d --name=redis redis:2.8.19
                            --name is necessary for --link (docker otherwise generates names automatically)docker run -d --link=redis:redis --name=flask-sse_gunicorn flask-sse_gunicorn
                            --link creates a DNS entry for redis, pointing to the IP of the containerdocker run -d -p 80:80 --link=flask-sse_gunicorn:flask-sse_gunicorn flask-sse_nginx
                            apt-get install -y (otherwise user interaction required)ENV MODIFIED_AT (can be changed to deactivate build-cache)docker exec allows to attach to a running container and start a command (e.g. /bin/bash for problem fixing)docker ps shows running containers, docker images existing imagesdocker stop/rm $(docker ps -a -q) stops/discards all containersdocker history shows layers of an imagesystemd unit files or fig can be used to start inter-dependent containersUSER www-data in the Dockerfile to let a command run as a user, or configure the process accordingly (e.g. user www-data; in nginx.conf)docker rm 3ecVOLUMEs can be used with --volumes-from, can be migrated with docker export