Download - Building Python Web Apps with Docker
Building PythonWeb Apps with
Docker
Mark Adams • Bitbucket Developer • Atlassian • @markadams
What we'll cover (hopefully)What is Docker?
A Python web app
Docker Engine
Docker Hub
Docker Compose
Docker Machine
What is
???
Traditional Virtual Machines
APP A APP B
LIBS LIBS
GUEST OS GUEST OS
HYPERVISOR
HOST OS
SERVER
Robust
Monolithic
Slow toboot
Heavy
Containers
APP A APP B
LIBS LIBS DOCKER
HOST OS
SERVER
Lean
Portable
Lightweight
Efficient
Isolated
Where are containers useful?
Local Development
CI BuildsJenkins, Bamboo, etc.
Deploying to productionand scaling!
Where do I get it?
Windows & MacDocker Toolbox
Installs Docker Client, Engine, Compose, Machine, Kitematic, and Virtualbox
Linux$ wget qO https://get.docker.com/ | sh
Downloads a shell script to install the right package for your system
Architecture
Demo App!https://bitbucket.org/markadams/pytexas-2015-demo
Docker EngineBuilds images and runs containers
Dockerfile
FROM python:3.4
EXPOSE 8000WORKDIR /usr/src/app
# Install dependenciesCOPY requirements.txt requirements.txtRUN pip install r requirements.txt
# Copy the rest of the application's codeCOPY . /usr/src/app
# Run the appCMD ["./run_app.sh"]
docker buildbuilds an image
docker runcreates a container from an image and runs it
docker logsshows the logs from a container
docker psshows what's running
Docker Hubhttp://hub.docker.com
$ docker pull ubuntu
Using default tag: latestlatest: Pulling from ubuntuDownloading 10.8 MB/158.6 MBfec9fec2e960: Download complete9f834db6fd2c: Download completeDownloading 5.7 MB/30.2 MBb13fbdab1f72: Download complete843e2bded498: Already exists
docker pushpushes to the repository
docker pullpulls an image from the repository
Public or Private
Docker ComposeDescribes the components of an application
YML Config
web: build: . links: 'db' ports: '8000:8000' environment: 'DATABASE_HOST=db' 'DATABASE_NAME=postgres' 'DATABASE_USER=postgres' 'DATABASE_PASSWORD=postgres'db: image: postgres:9.4
docker-compose upstarts all the containers
docker-composebuildrebuilds your images
docker-compose stopstopps the containers
Docker MachineProvisions and manages Docker hosts
Works with
amazonec2 azure digitalocean exoscale google openstack rackspace softlayer virtualbox vmwarevcloudair vmwarevsphere
docker-machine createcreates a new Docker host
docker-machine sshconnects to the host using SSH
docker-machine rmdestroys the host
docker-machine envsets environment variables for your client to
connect to the host
Demo
2:15
Orchestration!
Thank you!@markadams
https://bitbucket.org/markadams/pytexas-2015