SlideShare a Scribd company logo
1 of 28
Download to read offline
Shipping Python Projects
by Docker
Wei-Ting Kuo
Outline
• Introduction to Docker
• define our sample web app
• Build/Run Docker Images
• Docker Index
• Deploy to AWS
The Challenge
The Matrix From Hell
Cargo Transport Pre-1960
The Matrix From Hell
Solution: 

Intermodal Shipping Container
Docker is a shipping
container system for code
Docker eliminates the matrix
from hell
VMs vs Containers
Installation
(Ubuntu14.04)
• $ sudo apt-get update
• $ sudo apt-get install docker.io
• $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
Pull a Base Image
• docker pull ubuntu
List Docker Images
• docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 13.10 5e019ab7bf6d 3 weeks ago 180 MB
ubuntu saucy 5e019ab7bf6d 3 weeks ago 180 MB
ubuntu 12.04 74fe38d11401 3 weeks ago 209.6 MB
ubuntu precise 74fe38d11401 3 weeks ago 209.6 MB
ubuntu 12.10 a7cf8ae4e998 3 weeks ago 171.3 MB
ubuntu quantal a7cf8ae4e998 3 weeks ago 171.3 MB
ubuntu 14.04 99ec81b80c55 3 weeks ago 266 MB
ubuntu latest 99ec81b80c55 3 weeks ago 266 MB
ubuntu trusty 99ec81b80c55 3 weeks ago 266 MB
ubuntu raring 316b678ddf48 3 weeks ago 169.4 MB
ubuntu 13.04 316b678ddf48 3 weeks ago 169.4 MB
Run Something
• docker run <image> <command … >
• docker run ubuntu ls -l /root
drwxr-xr-x 2 root root 12288 Apr 16 20:36 bin
drwxr-xr-x 2 root root 4096 Apr 10 22:12 games
drwxr-xr-x 2 root root 4096 Apr 16 20:36 include
drwxr-xr-x 26 root root 4096 Apr 16 20:36 lib
drwxr-xr-x 10 root root 4096 Apr 16 20:35 local
drwxr-xr-x 2 root root 4096 Apr 24 16:17 sbin
drwxr-xr-x 52 root root 4096 Apr 16 20:36 share
drwxr-xr-x 2 root root 4096 Apr 10 22:12 src
Simple Flask App
• https://github.com/waitingkuo/flask-sample
• flask-sample

- app.py

- requirements.txt

- Dockerfile
app.py
from flask import Flask
app = Flask(__name__)
!
@app.route("/")
def hello():
return "Hello World!"
!
if __name__ == "__main__":
app.run(‘0.0.0.0’, port=5000)
Requirements.txt
flask
Install and Run 

flask-sample Locally
• sudo apt-get install -y python-setuptools
• sudo easy_install pip
• sudo pip install -r requirements.txt
• python app.py

* Running on http://0.0.0.0:5000/
How to build a 

Docker Image
• Dockerfile

http://docs.docker.io/reference/builder/
Dockerfile
FROM ubuntu
!
# Install Python Setuptools
RUN apt-get install -y python-setuptools
!
# Install pip
RUN easy_install pip
!
# Install requirements.txt
ADD requirements.txt /src/requirements.txt
RUN cd /src; pip install -r requirements.txt
!
# Add the Flask App
ADD . /src
!
# EXPOSE PORT
EXPOSE 5000
!
# Run the Flask APP
CMD python src/app.py
Build a Image
• docker build -t <image name> <Dockerfile PATH>
• docker build -t myapp .
Uploading context 76.29 kB
Uploading context
Step 0 : FROM ubuntu
---> 99ec81b80c55
Step 1 : RUN apt-get install -y python-setuptools
---> Using cache
---> d651a6cb230c
Step 2 : RUN easy_install pip
---> Using cache
---> ecf1474da849
Step 3 : ADD requirements.txt /src/requirements.txt
---> Using cache
---> 274c84b5415e
!
… (ignore) …
!
Successfully built b4c78de4abc1
Check Your new Image
• docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
myapp latest b4c78de4abc1 2 minutes ago 302.7 MB
ubuntu 13.10 5e019ab7bf6d 3 weeks ago 180 MB
ubuntu saucy 5e019ab7bf6d 3 weeks ago 180 MB
ubuntu 12.04 74fe38d11401 3 weeks ago 209.6 MB
ubuntu precise 74fe38d11401 3 weeks ago 209.6 MB
ubuntu 12.10 a7cf8ae4e998 3 weeks ago 171.3 MB
ubuntu quantal a7cf8ae4e998 3 weeks ago 171.3 MB
ubuntu 14.04 99ec81b80c55 3 weeks ago 266 MB
ubuntu latest 99ec81b80c55 3 weeks ago 266 MB
ubuntu trusty 99ec81b80c55 3 weeks ago 266 MB
ubuntu raring 316b678ddf48 3 weeks ago 169.4 MB
ubuntu 13.04 316b678ddf48 3 weeks ago 169.4 MB
Run It!
• docker run -d -p 5000:5000 myapp



-d detached mode

-p port forwarding
How to check the 

Running Docker Process?
• docker ps
CONTAINER ID IMAGE COMMAND … PORTS
6294c5a5e9be myapp:latest /bin/sh -c 'python s … 0.0.0.0:5000->5000/tcp
• To kill the process, use

docker kill <CONTAINER ID>
Docker Index
• https://index.docker.io/
• You might think it as the GitHub For Docker Image
• You can pull mysql, mongodb, hadoop, … etc
• You can hook your docker index repository on to
your own repository on GitHub!!!



-> Build images automatically once you push something to Github
The Repository for our 

flask-sample
• https://index.docker.io/u/waitingkuo/flask-sample/
Deploy!
• Use whatever you want to login to your production
server (ssh, fabric, capistrano, chef, puppet, ….)
• docker pull waitingkuo/flask-sample
• docker run -d -p 5000:5000 waitingkuo/flask-
sample
• Thank you :)

More Related Content

What's hot

Docker, Mesos, Spark
Docker, Mesos, Spark Docker, Mesos, Spark
Docker, Mesos, Spark Qiang Wang
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetesDongwon Kim
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...Atlassian
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5rajdeep
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and dockerFabio Fumarola
 
Docker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesDocker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesSreenivas Makam
 
Cassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedCassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedDataStax Academy
 
CoreOS Overview and Current Status
CoreOS Overview and Current StatusCoreOS Overview and Current Status
CoreOS Overview and Current StatusSreenivas Makam
 
Introducing Docker Swarm - the orchestration tool by Docker
Introducing Docker Swarm - the orchestration tool by DockerIntroducing Docker Swarm - the orchestration tool by Docker
Introducing Docker Swarm - the orchestration tool by DockerRamit Surana
 
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera Docker, Inc.
 
Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28Sadique Puthen
 
From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017
From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017
From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017Frank Munz
 
Scaling and Managing Cassandra with docker, CoreOS and Presto
Scaling and Managing Cassandra with docker, CoreOS and PrestoScaling and Managing Cassandra with docker, CoreOS and Presto
Scaling and Managing Cassandra with docker, CoreOS and PrestoVali-Marius Malinoiu
 
Unikernels and docker from revolution to evolution — unikernels and docker ...
Unikernels and docker  from revolution to evolution — unikernels and docker  ...Unikernels and docker  from revolution to evolution — unikernels and docker  ...
Unikernels and docker from revolution to evolution — unikernels and docker ...Docker, Inc.
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...dotCloud
 
Docker Networking : 0 to 60mph slides
Docker Networking : 0 to 60mph slidesDocker Networking : 0 to 60mph slides
Docker Networking : 0 to 60mph slidesDocker, Inc.
 
DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...
DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...
DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...ClusterHQ
 
Wanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerWanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerEwout Prangsma
 

What's hot (20)

Docker, Mesos, Spark
Docker, Mesos, Spark Docker, Mesos, Spark
Docker, Mesos, Spark
 
What's New in Docker 1.12?
What's New in Docker 1.12?What's New in Docker 1.12?
What's New in Docker 1.12?
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
AtlasCamp 2015: The age of orchestration: From Docker basics to cluster manag...
 
Docker 1.5
Docker 1.5Docker 1.5
Docker 1.5
 
Develop with linux containers and docker
Develop with linux containers and dockerDevelop with linux containers and docker
Develop with linux containers and docker
 
Container orchestration
Container orchestrationContainer orchestration
Container orchestration
 
Docker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notesDocker Mentorweek beginner workshop notes
Docker Mentorweek beginner workshop notes
 
Cassandra and Docker Lessons Learned
Cassandra and Docker Lessons LearnedCassandra and Docker Lessons Learned
Cassandra and Docker Lessons Learned
 
CoreOS Overview and Current Status
CoreOS Overview and Current StatusCoreOS Overview and Current Status
CoreOS Overview and Current Status
 
Introducing Docker Swarm - the orchestration tool by Docker
Introducing Docker Swarm - the orchestration tool by DockerIntroducing Docker Swarm - the orchestration tool by Docker
Introducing Docker Swarm - the orchestration tool by Docker
 
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
Moving Legacy Applications to Docker by Josh Ellithorpe, Apcera
 
Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28Introduction openstack-meetup-nov-28
Introduction openstack-meetup-nov-28
 
From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017
From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017
From Docker Swarm to OCCS and Wercker: Live-hacking at Oracle CODE Mexico 2017
 
Scaling and Managing Cassandra with docker, CoreOS and Presto
Scaling and Managing Cassandra with docker, CoreOS and PrestoScaling and Managing Cassandra with docker, CoreOS and Presto
Scaling and Managing Cassandra with docker, CoreOS and Presto
 
Unikernels and docker from revolution to evolution — unikernels and docker ...
Unikernels and docker  from revolution to evolution — unikernels and docker  ...Unikernels and docker  from revolution to evolution — unikernels and docker  ...
Unikernels and docker from revolution to evolution — unikernels and docker ...
 
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
Deploying containers and managing them on multiple Docker hosts, Docker Meetu...
 
Docker Networking : 0 to 60mph slides
Docker Networking : 0 to 60mph slidesDocker Networking : 0 to 60mph slides
Docker Networking : 0 to 60mph slides
 
DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...
DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...
DockerCon 2016 Ecosystem - Everything You Need to Know About Docker and Stora...
 
Wanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerWanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-docker
 

Similar to Dockerizing Python Projects

Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Ontico
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with AnsibleBas Meijer
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...NLJUG
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK SeminarMartin Scharm
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in descriptionPrzemyslaw Koltermann
 
Docker module 1
Docker module 1Docker module 1
Docker module 1Liang Bo
 
Work shop - an introduction to the docker ecosystem
Work shop - an introduction to the docker ecosystemWork shop - an introduction to the docker ecosystem
Work shop - an introduction to the docker ecosystemJoão Pedro Harbs
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to dockerWei-Ting Kuo
 
Docker in Continuous Integration
Docker in Continuous IntegrationDocker in Continuous Integration
Docker in Continuous IntegrationAlexander Akbashev
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortalsHenryk Konsek
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLandJohan Janssen
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoHannes Hapke
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...Eric Smalling
 
Networking in Kubernetes
Networking in KubernetesNetworking in Kubernetes
Networking in KubernetesMinhan Xia
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session DockerLinetsChile
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by DockerTerry Chen
 

Similar to Dockerizing Python Projects (20)

Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Docker as an every day work tool
Docker as an every day work toolDocker as an every day work tool
Docker as an every day work tool
 
docker build with Ansible
docker build with Ansibledocker build with Ansible
docker build with Ansible
 
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
Gebruik dezelfde Docker container voor Java applicaties tijdens ontwikkelen e...
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK Seminar
 
Check the version with fixes. Link in description
Check the version with fixes. Link in descriptionCheck the version with fixes. Link in description
Check the version with fixes. Link in description
 
Docker module 1
Docker module 1Docker module 1
Docker module 1
 
Work shop - an introduction to the docker ecosystem
Work shop - an introduction to the docker ecosystemWork shop - an introduction to the docker ecosystem
Work shop - an introduction to the docker ecosystem
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Docker in Continuous Integration
Docker in Continuous IntegrationDocker in Continuous Integration
Docker in Continuous Integration
 
Docker for mere mortals
Docker for mere mortalsDocker for mere mortals
Docker for mere mortals
 
Docker for Java developers at JavaLand
Docker for Java developers at JavaLandDocker for Java developers at JavaLand
Docker for Java developers at JavaLand
 
PDXPortland - Dockerize Django
PDXPortland - Dockerize DjangoPDXPortland - Dockerize Django
PDXPortland - Dockerize Django
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
Docker
DockerDocker
Docker
 
Networking in Kubernetes
Networking in KubernetesNetworking in Kubernetes
Networking in Kubernetes
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Hands-On Session Docker
Hands-On Session DockerHands-On Session Docker
Hands-On Session Docker
 
Docker basic
Docker basicDocker basic
Docker basic
 
Develop QNAP NAS App by Docker
Develop QNAP NAS App by DockerDevelop QNAP NAS App by Docker
Develop QNAP NAS App by Docker
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

Dockerizing Python Projects

  • 1. Shipping Python Projects by Docker Wei-Ting Kuo
  • 2. Outline • Introduction to Docker • define our sample web app • Build/Run Docker Images • Docker Index • Deploy to AWS
  • 8. Docker is a shipping container system for code
  • 9. Docker eliminates the matrix from hell
  • 11. Installation (Ubuntu14.04) • $ sudo apt-get update • $ sudo apt-get install docker.io • $ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
  • 12. Pull a Base Image • docker pull ubuntu
  • 13. List Docker Images • docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ubuntu 13.10 5e019ab7bf6d 3 weeks ago 180 MB ubuntu saucy 5e019ab7bf6d 3 weeks ago 180 MB ubuntu 12.04 74fe38d11401 3 weeks ago 209.6 MB ubuntu precise 74fe38d11401 3 weeks ago 209.6 MB ubuntu 12.10 a7cf8ae4e998 3 weeks ago 171.3 MB ubuntu quantal a7cf8ae4e998 3 weeks ago 171.3 MB ubuntu 14.04 99ec81b80c55 3 weeks ago 266 MB ubuntu latest 99ec81b80c55 3 weeks ago 266 MB ubuntu trusty 99ec81b80c55 3 weeks ago 266 MB ubuntu raring 316b678ddf48 3 weeks ago 169.4 MB ubuntu 13.04 316b678ddf48 3 weeks ago 169.4 MB
  • 14. Run Something • docker run <image> <command … > • docker run ubuntu ls -l /root drwxr-xr-x 2 root root 12288 Apr 16 20:36 bin drwxr-xr-x 2 root root 4096 Apr 10 22:12 games drwxr-xr-x 2 root root 4096 Apr 16 20:36 include drwxr-xr-x 26 root root 4096 Apr 16 20:36 lib drwxr-xr-x 10 root root 4096 Apr 16 20:35 local drwxr-xr-x 2 root root 4096 Apr 24 16:17 sbin drwxr-xr-x 52 root root 4096 Apr 16 20:36 share drwxr-xr-x 2 root root 4096 Apr 10 22:12 src
  • 15. Simple Flask App • https://github.com/waitingkuo/flask-sample • flask-sample
 - app.py
 - requirements.txt
 - Dockerfile
  • 16. app.py from flask import Flask app = Flask(__name__) ! @app.route("/") def hello(): return "Hello World!" ! if __name__ == "__main__": app.run(‘0.0.0.0’, port=5000)
  • 18. Install and Run 
 flask-sample Locally • sudo apt-get install -y python-setuptools • sudo easy_install pip • sudo pip install -r requirements.txt • python app.py
 * Running on http://0.0.0.0:5000/
  • 19. How to build a 
 Docker Image • Dockerfile
 http://docs.docker.io/reference/builder/
  • 20. Dockerfile FROM ubuntu ! # Install Python Setuptools RUN apt-get install -y python-setuptools ! # Install pip RUN easy_install pip ! # Install requirements.txt ADD requirements.txt /src/requirements.txt RUN cd /src; pip install -r requirements.txt ! # Add the Flask App ADD . /src ! # EXPOSE PORT EXPOSE 5000 ! # Run the Flask APP CMD python src/app.py
  • 21. Build a Image • docker build -t <image name> <Dockerfile PATH> • docker build -t myapp . Uploading context 76.29 kB Uploading context Step 0 : FROM ubuntu ---> 99ec81b80c55 Step 1 : RUN apt-get install -y python-setuptools ---> Using cache ---> d651a6cb230c Step 2 : RUN easy_install pip ---> Using cache ---> ecf1474da849 Step 3 : ADD requirements.txt /src/requirements.txt ---> Using cache ---> 274c84b5415e ! … (ignore) … ! Successfully built b4c78de4abc1
  • 22. Check Your new Image • docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE myapp latest b4c78de4abc1 2 minutes ago 302.7 MB ubuntu 13.10 5e019ab7bf6d 3 weeks ago 180 MB ubuntu saucy 5e019ab7bf6d 3 weeks ago 180 MB ubuntu 12.04 74fe38d11401 3 weeks ago 209.6 MB ubuntu precise 74fe38d11401 3 weeks ago 209.6 MB ubuntu 12.10 a7cf8ae4e998 3 weeks ago 171.3 MB ubuntu quantal a7cf8ae4e998 3 weeks ago 171.3 MB ubuntu 14.04 99ec81b80c55 3 weeks ago 266 MB ubuntu latest 99ec81b80c55 3 weeks ago 266 MB ubuntu trusty 99ec81b80c55 3 weeks ago 266 MB ubuntu raring 316b678ddf48 3 weeks ago 169.4 MB ubuntu 13.04 316b678ddf48 3 weeks ago 169.4 MB
  • 23. Run It! • docker run -d -p 5000:5000 myapp
 
 -d detached mode
 -p port forwarding
  • 24. How to check the 
 Running Docker Process? • docker ps CONTAINER ID IMAGE COMMAND … PORTS 6294c5a5e9be myapp:latest /bin/sh -c 'python s … 0.0.0.0:5000->5000/tcp • To kill the process, use
 docker kill <CONTAINER ID>
  • 25. Docker Index • https://index.docker.io/ • You might think it as the GitHub For Docker Image • You can pull mysql, mongodb, hadoop, … etc • You can hook your docker index repository on to your own repository on GitHub!!!
 
 -> Build images automatically once you push something to Github
  • 26. The Repository for our 
 flask-sample • https://index.docker.io/u/waitingkuo/flask-sample/
  • 27. Deploy! • Use whatever you want to login to your production server (ssh, fabric, capistrano, chef, puppet, ….) • docker pull waitingkuo/flask-sample • docker run -d -p 5000:5000 waitingkuo/flask- sample