Azure Workshop Docker for Python Developer Wei-Ting Kuo
Workshop Steps
• Use Docker-Machine to create VM on Azure
• Build your Python web app
• Build Docker Image and deploy to Azure by Docker
• Improve deployment process by Docker-Compose
Step1 Use Docker-Machine to Create VM
• 1. Download your publish setting file
• 2. Install Docker & Docker Machine
• 3. Use Docker-Machine to create a virtual machine on Azure
Download PublishSettings
• Install Azure command line tool:Source: https://github.com/azure/azure-xplat-cli Windows: http://go.microsoft.com/fwlink/?linkid=254279 Mac: http://go.microsoft.com/fwlink/?Linkid=252249 Linux: http://go.microsoft.com/fwlink/?linkid=253472
• Download your publishsettings file $ azure account download
Install Docker (Mac)
• Documenthttps://docs.docker.com/installation/mac/
• https://github.com/boot2docker/osx-installer/releases/latest
Install Docker (Linux)
• Documenthttps://docs.docker.com/installation/ubuntulinux/
• $ sudo apt-get update $ sudo apt-get install wget $ wget -qO- https://get.docker.com/ | sh
Install Docker (Windows)
• Documenthttps://docs.docker.com/installation/windows/
• Installer https://github.com/boot2docker/windows-installer/releases/latest
Install Docker Machine (Mac & Linux)
• Documenthttps://docs.docker.com/machine/
• Install $ curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine $ chmod +x /usr/local/bin/docker-machine
Install Docker Machine (Windows)
• Documenthttps://docs.docker.com/machine/
• Install opensslhttp://gnuwin32.sourceforge.net/packages/openssl.htm
• Install Docker Machine $ curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_windows-amd64.exe > /bin/docker-machine
Create a Virtual Machine on Azure (with Docker)
• Create a Machine on Azure with Docker $ docker-machine create -d azure --azure-publish-settings-file PUBLISH-SETTING-FILE A-VERY-UNIQUE-NAME
• Setup docker environment to connect to your new instance $ eval `docker-machine env A-VERY-UNIQUE-NAME`
Demo
• Some basic Docker commands
• docker info docker pull ubuntu docker run ubuntu ls docker imagesdocker ps
Step 2 Build Your Python Web App
• 1. Add requirements.txt
• 2. Build a very simple python web app
• 3. Write a Dockerfile
• 4. build the image
• 5. Deploy it to Azure
Sample Codes
• Please git clone this repo $ git clone https://github.com/waitingkuo/pyconapac2015-azure-workshop
Deploy to Azure• Run redis first
$ docker run -d --name myredis redis
• Check status $ docker ps
• Run your web app$ docker run -d -p 80:5000 --link myredis:redis myapp
• Check status $ docker ps
Connect to your server
• http://YOUR-MACHINE-NAME.cloudapp.net
• mine is http://pyconapac2015-azure.cloudapp.net