Building Python Web Apps with Docker

Download Building Python Web Apps with Docker

Post on 12-Apr-2017

1.217 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

<ul><li><p>Building PythonWeb Apps with</p><p>Docker</p><p>Mark Adams Bitbucket Developer Atlassian @markadams</p><p>https://twitter.com/markadams</p></li><li><p>What we'll cover (hopefully)What is Docker?</p><p>A Python web app</p><p>Docker Engine</p><p>Docker Hub</p><p>Docker Compose</p><p>Docker Machine</p></li><li><p>What is </p><p>???</p></li><li><p>Traditional Virtual Machines</p><p>APP A APP B</p><p>LIBS LIBS</p><p>GUEST OS GUEST OS</p><p>HYPERVISOR</p><p>HOST OS</p><p>SERVER</p><p>Robust</p><p>Monolithic</p><p>Slow toboot</p><p>Heavy</p></li><li><p>Containers</p><p>APP A APP B</p><p>LIBS LIBS DOCKER</p><p>HOST OS</p><p>SERVER</p><p>Lean</p><p>Portable</p><p>Lightweight</p><p>Efficient</p><p>Isolated</p></li><li><p>Where are containers useful?</p></li><li><p>Local Development</p></li><li><p>CI BuildsJenkins, Bamboo, etc.</p></li><li><p>Deploying to productionand scaling!</p></li><li><p>Where do I get it?</p></li><li><p>Windows &amp; MacDocker Toolbox</p><p>Installs Docker Client, Engine, Compose, Machine, Kitematic, and Virtualbox</p></li><li><p>Linux$wgetqOhttps://get.docker.com/|sh</p><p>Downloads a shell script to install the right package for your system</p></li><li><p>Architecture</p></li><li><p>Demo App!https://bitbucket.org/markadams/pytexas-2015-demo</p><p>https://bitbucket.org/markadams/pytexas-2015-demo</p></li><li><p>Docker EngineBuilds images and runs containers</p><p>Dockerfile</p><p>FROMpython:3.4</p><p>EXPOSE8000WORKDIR/usr/src/app</p><p>#InstalldependenciesCOPYrequirements.txtrequirements.txtRUNpipinstallrrequirements.txt</p><p>#Copytherestoftheapplication'scodeCOPY./usr/src/app</p><p>#RuntheappCMD["./run_app.sh"]</p><p>docker buildbuilds an image</p><p>docker runcreates a container from an image and runs it</p><p>docker logsshows the logs from a container</p><p>docker psshows what's running</p></li><li><p>Docker Hubhttp://hub.docker.com</p><p>$dockerpullubuntu</p><p>Usingdefaulttag:latestlatest:PullingfromubuntuDownloading10.8MB/158.6MBfec9fec2e960:Downloadcomplete9f834db6fd2c:DownloadcompleteDownloading5.7MB/30.2MBb13fbdab1f72:Downloadcomplete843e2bded498:Alreadyexists</p><p>docker pushpushes to the repository</p><p>docker pullpulls an image from the repository</p><p>Public or Private</p><p>http://hub.docker.com/</p></li><li><p>Docker ComposeDescribes the components of an application</p><p>YML Config</p><p>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</p><p>docker-compose upstarts all the containers</p><p>docker-composebuildrebuilds your images</p><p>docker-compose stopstopps the containers</p></li><li><p>Docker MachineProvisions and manages Docker hosts</p><p>Works with</p><p>amazonec2azuredigitaloceanexoscalegoogleopenstackrackspacesoftlayervirtualboxvmwarevcloudairvmwarevsphere </p><p>docker-machine createcreates a new Docker host</p><p>docker-machine sshconnects to the host using SSH</p><p>docker-machine rmdestroys the host</p><p>docker-machine envsets environment variables for your client to</p><p>connect to the host</p></li><li><p>Demo</p><p>2:15</p></li><li><p>Orchestration!</p></li><li><p>Thank you!@markadams</p><p>https://bitbucket.org/markadams/pytexas-2015</p><p>https://twitter.com/markadamshttps://bitbucket.org/markadams/pytexas-2015</p></li></ul>