Building Python Web Apps with Docker

  • Published on
    12-Apr-2017

  • View
    1.217

  • Download
    0

Transcript

Building PythonWeb Apps withDockerMark Adams Bitbucket Developer Atlassian @markadamshttps://twitter.com/markadamsWhat we'll cover (hopefully)What is Docker?A Python web appDocker EngineDocker HubDocker ComposeDocker MachineWhat is ???Traditional Virtual MachinesAPP A APP BLIBS LIBSGUEST OS GUEST OSHYPERVISORHOST OSSERVERRobustMonolithicSlow tobootHeavyContainersAPP A APP BLIBS LIBS DOCKERHOST OSSERVERLeanPortableLightweightEfficientIsolatedWhere are containers useful?Local DevelopmentCI BuildsJenkins, Bamboo, etc.Deploying to productionand scaling!Where do I get it?Windows & MacDocker ToolboxInstalls Docker Client, Engine, Compose, Machine, Kitematic, and VirtualboxLinux$wgetqOhttps://get.docker.com/|shDownloads a shell script to install the right package for your systemArchitectureDemo App!https://bitbucket.org/markadams/pytexas-2015-demohttps://bitbucket.org/markadams/pytexas-2015-demoDocker EngineBuilds images and runs containersDockerfileFROMpython:3.4EXPOSE8000WORKDIR/usr/src/app#InstalldependenciesCOPYrequirements.txtrequirements.txtRUNpipinstallrrequirements.txt#Copytherestoftheapplication'scodeCOPY./usr/src/app#RuntheappCMD["./run_app.sh"]docker buildbuilds an imagedocker runcreates a container from an image and runs itdocker logsshows the logs from a containerdocker psshows what's runningDocker Hubhttp://hub.docker.com$dockerpullubuntuUsingdefaulttag:latestlatest:PullingfromubuntuDownloading10.8MB/158.6MBfec9fec2e960:Downloadcomplete9f834db6fd2c:DownloadcompleteDownloading5.7MB/30.2MBb13fbdab1f72:Downloadcomplete843e2bded498:Alreadyexistsdocker pushpushes to the repositorydocker pullpulls an image from the repositoryPublic or Privatehttp://hub.docker.com/Docker ComposeDescribes the components of an applicationYML Configweb:build:.links:'db'ports:'8000:8000'environment:'DATABASE_HOST=db''DATABASE_NAME=postgres''DATABASE_USER=postgres''DATABASE_PASSWORD=postgres'db:image:postgres:9.4docker-compose upstarts all the containersdocker-composebuildrebuilds your imagesdocker-compose stopstopps the containersDocker MachineProvisions and manages Docker hostsWorks withamazonec2azuredigitaloceanexoscalegoogleopenstackrackspacesoftlayervirtualboxvmwarevcloudairvmwarevsphere docker-machine createcreates a new Docker hostdocker-machine sshconnects to the host using SSHdocker-machine rmdestroys the hostdocker-machine envsets environment variables for your client toconnect to the hostDemo2:15Orchestration!Thank you!@markadamshttps://bitbucket.org/markadams/pytexas-2015https://twitter.com/markadamshttps://bitbucket.org/markadams/pytexas-2015