What docker containers can do for the Python developer
Let's start filling your head!
$> docker run -i -t python:2 $> docker run -i -t python:3
Note:
$> docker run -it -p 8888:8888 \ python:3 python -m http.server 8888 $> curl -i <server>:8888
$> docker info
$> docker stats $> docker run -it -d --name utnubu ubuntu $> docker inspect utnubu | jq '.' $> docker exec -it utnubu /bin/bash $> # ps, top, uname -a, apt-get, what you want
using a little Dockerfile to build our own image
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
FROM python:3 ADD ./app.py app.py RUN pip install flask EXPOSE 5000 CMD ["python", "app.py"]
/tmp/flaskapp $> tree . ├── Dockerfile └── app.py
$> docker build -t demoapp . $> docker images $> docker run -d -p 8888:5000 demoapp $> docker ps $> open http://$(docker-machine ip):8888/
User friendly & lightweight
Solves the dependency hell
Reusability by design
Client/server RESTful communication API
Promotes github-like community and collaboration through a public registry (or your private registry)
Data in- and output is
(tar-)file based
Massive, growing ecosystem
Dockerfiles feel restrictive and dowdy compared to ansible playbooks for example
Then again: Integration in Ansible is great!
No orchestration built in, this has been solved by docker swarm
The Docker volumes are an afterthought, not a first class citizen, this has been addressed by the `docker volume` subcommand
Security (more room for privilege-escalation and human error)